author | zautrix <zautrix> | 2005-02-04 10:23:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-04 10:23:55 (UTC) |
commit | 83256090c493dab56f1afba4829e864598bf70d2 (patch) (unidiff) | |
tree | 8d5b7ee0c6fe42f0f14c53b80c924ccddd5a1599 /kmicromail | |
parent | a96872e5ecff3a8fb1785aff71f5f7f150ef8604 (diff) | |
download | kdepimpi-83256090c493dab56f1afba4829e864598bf70d2.zip kdepimpi-83256090c493dab56f1afba4829e864598bf70d2.tar.gz kdepimpi-83256090c493dab56f1afba4829e864598bf70d2.tar.bz2 |
mail send
-rw-r--r-- | kmicromail/composemail.cpp | 14 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 33 | ||||
-rw-r--r-- | kmicromail/opiemail.h | 5 |
3 files changed, 48 insertions, 4 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index ed8a2ee..3231b45 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -1,530 +1,538 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | 2 | ||
3 | 3 | ||
4 | #ifdef DESKTOP_VERSION | 4 | #ifdef DESKTOP_VERSION |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include <kabc/addresseedialog.h> | 6 | #include <kabc/addresseedialog.h> |
7 | #include <kabc/stdaddressbook.h> | 7 | #include <kabc/stdaddressbook.h> |
8 | #include <kabc/addressee.h> | 8 | #include <kabc/addressee.h> |
9 | #else | 9 | #else |
10 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
11 | #endif //DESKTOP_VERSION | 11 | #endif //DESKTOP_VERSION |
12 | #include <libkdepim/externalapphandler.h> | 12 | #include <libkdepim/externalapphandler.h> |
13 | 13 | ||
14 | #include "koprefs.h" | 14 | #include "koprefs.h" |
15 | #include <klocale.h> | 15 | #include <klocale.h> |
16 | #include <kglobal.h> | 16 | #include <kglobal.h> |
17 | 17 | ||
18 | #ifdef MINIKDE_KDIALOG_H | 18 | #ifdef MINIKDE_KDIALOG_H |
19 | #undef MINIKDE_KDIALOG_H | 19 | #undef MINIKDE_KDIALOG_H |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | 22 | ||
23 | #include "composemail.h" | 23 | #include "composemail.h" |
24 | 24 | ||
25 | #include <libmailwrapper/smtpwrapper.h> | 25 | #include <libmailwrapper/smtpwrapper.h> |
26 | #include <libmailwrapper/storemail.h> | 26 | #include <libmailwrapper/storemail.h> |
27 | #include <libmailwrapper/abstractmail.h> | 27 | #include <libmailwrapper/abstractmail.h> |
28 | #include <libmailwrapper/mailtypes.h> | 28 | #include <libmailwrapper/mailtypes.h> |
29 | 29 | ||
30 | /* OPIE */ | 30 | /* OPIE */ |
31 | //#include <opie2/ofiledialog.h> | 31 | //#include <opie2/ofiledialog.h> |
32 | //#include <opie2/odebug.h> | 32 | //#include <opie2/odebug.h> |
33 | #include <kfiledialog.h> | 33 | #include <kfiledialog.h> |
34 | //#include <qpe/resource.h> | 34 | //#include <qpe/resource.h> |
35 | #include <qpe/global.h> | 35 | #include <qpe/global.h> |
36 | //#include <qpe/contact.h> | 36 | //#include <qpe/contact.h> |
37 | 37 | ||
38 | 38 | ||
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qiconset.h> | 41 | #include <qiconset.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qmultilineedit.h> | 45 | #include <qmultilineedit.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qtabwidget.h> | 47 | #include <qtabwidget.h> |
48 | #include <qlistview.h> | 48 | #include <qlistview.h> |
49 | 49 | ||
50 | //using namespace Opie::Core; | 50 | //using namespace Opie::Core; |
51 | //using namespace Opie::Ui; | 51 | //using namespace Opie::Ui; |
52 | ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal ) | 52 | ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal ) |
53 | : ComposeMailUI( parent, name, modal ) | 53 | : ComposeMailUI( parent, name, modal ) |
54 | { | 54 | { |
55 | 55 | ||
56 | mPickLineEdit = 0; | 56 | mPickLineEdit = 0; |
57 | mEncoding = KOPrefs::instance()->mCurrentCodeName; | 57 | mEncoding = KOPrefs::instance()->mCurrentCodeName; |
58 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 58 | //managed from opiemail now |
59 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 59 | //connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
60 | // this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | ||
60 | settings = sett; | 61 | settings = sett; |
61 | m_replyid = ""; | 62 | m_replyid = ""; |
62 | if ( KOPrefs::instance()->mUseKapi) { | 63 | if ( KOPrefs::instance()->mUseKapi) { |
63 | KConfig config( locateLocal("config", "kabcrc") ); | 64 | KConfig config( locateLocal("config", "kabcrc") ); |
64 | config.setGroup( "General" ); | 65 | config.setGroup( "General" ); |
65 | QString whoami_uid = config.readEntry( "WhoAmI" ); | 66 | QString whoami_uid = config.readEntry( "WhoAmI" ); |
66 | 67 | ||
67 | if ( whoami_uid.isEmpty() ) { | 68 | if ( whoami_uid.isEmpty() ) { |
68 | QMessageBox::information( 0, i18n( "Hint" ), | 69 | QMessageBox::information( 0, i18n( "Hint" ), |
69 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 70 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
70 | i18n( "Ok" ) ); | 71 | i18n( "Ok" ) ); |
71 | 72 | ||
72 | 73 | ||
73 | fillSettings(); | 74 | fillSettings(); |
74 | } else | 75 | } else |
75 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | 76 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); |
76 | 77 | ||
77 | 78 | ||
78 | #ifdef DESKTOP_VERSION | 79 | #ifdef DESKTOP_VERSION |
79 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 80 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
80 | QStringList mails = con.emails(); | 81 | QStringList mails = con.emails(); |
81 | QString defmail = con.preferredEmail(); | 82 | QString defmail = con.preferredEmail(); |
82 | if ( mails.count() == 0) | 83 | if ( mails.count() == 0) |
83 | QMessageBox::information( 0, i18n( "Hint" ), | 84 | QMessageBox::information( 0, i18n( "Hint" ), |
84 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 85 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
85 | i18n( "Ok" ) ); | 86 | i18n( "Ok" ) ); |
86 | if (defmail.length()!=0) { | 87 | if (defmail.length()!=0) { |
87 | fromBox->insertItem(defmail); | 88 | fromBox->insertItem(defmail); |
88 | } | 89 | } |
89 | QStringList::ConstIterator sit = mails.begin(); | 90 | QStringList::ConstIterator sit = mails.begin(); |
90 | for (;sit!=mails.end();++sit) { | 91 | for (;sit!=mails.end();++sit) { |
91 | if ( (*sit)==defmail) | 92 | if ( (*sit)==defmail) |
92 | continue; | 93 | continue; |
93 | fromBox->insertItem((*sit)); | 94 | fromBox->insertItem((*sit)); |
94 | } | 95 | } |
95 | senderNameEdit->setText(con.formattedName()); | 96 | senderNameEdit->setText(con.formattedName()); |
96 | #endif | 97 | #endif |
97 | 98 | ||
98 | } else { | 99 | } else { |
99 | fillSettings(); | 100 | fillSettings(); |
100 | } | 101 | } |
101 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); | 102 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); |
102 | 103 | ||
103 | attList->addColumn( i18n( "Name" ) ); | 104 | attList->addColumn( i18n( "Name" ) ); |
104 | attList->addColumn( i18n( "Size" ) ); | 105 | attList->addColumn( i18n( "Size" ) ); |
105 | QList<Account> accounts = settings->getAccounts(); | 106 | QList<Account> accounts = settings->getAccounts(); |
106 | 107 | ||
107 | if ( QApplication::desktop()->width() < 320 ) | 108 | if ( QApplication::desktop()->width() < 320 ) |
108 | smtpAccountBox->setMaximumWidth( 80 ); | 109 | smtpAccountBox->setMaximumWidth( 80 ); |
109 | Account *it; | 110 | Account *it; |
110 | for ( it = accounts.first(); it; it = accounts.next() ) { | 111 | for ( it = accounts.first(); it; it = accounts.next() ) { |
111 | if ( it->getType()==MAILLIB::A_SMTP ) { | 112 | if ( it->getType()==MAILLIB::A_SMTP ) { |
112 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 113 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
113 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 114 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
114 | smtpAccounts.append( smtp ); | 115 | smtpAccounts.append( smtp ); |
115 | } | 116 | } |
116 | } | 117 | } |
117 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 118 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
118 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 119 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
119 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 120 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
120 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 121 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
121 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 122 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
122 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 123 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
123 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 124 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
124 | mMail = 0; | 125 | mMail = 0; |
125 | warnAttach = true; | 126 | warnAttach = true; |
126 | QIconSet icon; | 127 | QIconSet icon; |
127 | //icon = SmallIcon("fileexport"); | 128 | //icon = SmallIcon("fileexport"); |
128 | icon = SmallIcon("filesave"); | 129 | icon = SmallIcon("filesave"); |
129 | SaveButton->setIconSet (icon ) ; | 130 | SaveButton->setIconSet (icon ) ; |
130 | if ( QApplication::desktop()->width() < 320 ) { | 131 | if ( QApplication::desktop()->width() < 320 ) { |
131 | SaveButton->setText ("") ; | 132 | SaveButton->setText ("") ; |
132 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; | 133 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; |
133 | } | 134 | } |
134 | else | 135 | else |
135 | SaveButton->setText (i18n("Save")); | 136 | SaveButton->setText (i18n("Save")); |
136 | #ifndef DESKTOP_VERSION | 137 | #ifndef DESKTOP_VERSION |
137 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); | 138 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); |
138 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); | 139 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); |
139 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); | 140 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); |
140 | #endif | 141 | #endif |
141 | message->setFont ( KOPrefs::instance()->mComposeFont ); | 142 | message->setFont ( KOPrefs::instance()->mComposeFont ); |
142 | message->setWordWrap (QMultiLineEdit::WidgetWidth); | 143 | message->setWordWrap (QMultiLineEdit::WidgetWidth); |
143 | if ( smtpAccounts.count() > 0 ) { | 144 | if ( smtpAccounts.count() > 0 ) { |
144 | fillValues( smtpAccountBox->currentItem() ); | 145 | fillValues( smtpAccountBox->currentItem() ); |
145 | } else { | 146 | } else { |
146 | QMessageBox::information( 0, i18n( "Problem" ), | 147 | QMessageBox::information( 0, i18n( "Problem" ), |
147 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), | 148 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), |
148 | i18n( "Ok" ) ); | 149 | i18n( "Ok" ) ); |
149 | return; | 150 | return; |
150 | } | 151 | } |
151 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 152 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
152 | connect( SaveSigButton, SIGNAL( clicked() ), SLOT( saveSig()) ); | 153 | connect( SaveSigButton, SIGNAL( clicked() ), SLOT( saveSig()) ); |
153 | if ( smtpAccountBox->count()) | 154 | if ( smtpAccountBox->count()) |
154 | fillValues(0); | 155 | fillValues(0); |
155 | 156 | ||
156 | } | 157 | } |
157 | 158 | ||
158 | void ComposeMail::fillSettings() | 159 | void ComposeMail::fillSettings() |
159 | { | 160 | { |
160 | if ( QApplication::desktop()->width() < 320 ) | 161 | if ( QApplication::desktop()->width() < 320 ) |
161 | fromBox->setMaximumWidth( 100 ); | 162 | fromBox->setMaximumWidth( 100 ); |
162 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); | 163 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); |
163 | QStringList::ConstIterator sit = mailList.begin(); | 164 | QStringList::ConstIterator sit = mailList.begin(); |
164 | int pref = 0; | 165 | int pref = 0; |
165 | for (;sit!=mailList.end();++sit) { | 166 | for (;sit!=mailList.end();++sit) { |
166 | fromBox->insertItem((*sit)); | 167 | fromBox->insertItem((*sit)); |
167 | } | 168 | } |
168 | senderNameEdit->setText(KOPrefs::instance()->mName); | 169 | senderNameEdit->setText(KOPrefs::instance()->mName); |
169 | } | 170 | } |
170 | void ComposeMail::saveSig() | 171 | void ComposeMail::saveSig() |
171 | { | 172 | { |
172 | if ( smtpAccountBox->count()) { | 173 | if ( smtpAccountBox->count()) { |
173 | int cur = smtpAccountBox->currentItem (); | 174 | int cur = smtpAccountBox->currentItem (); |
174 | SMTPaccount *smtp = smtpAccounts.at( cur ); | 175 | SMTPaccount *smtp = smtpAccounts.at( cur ); |
175 | if ( smtp ) | 176 | if ( smtp ) |
176 | smtp->setSignature( sigMultiLine->text()); | 177 | smtp->setSignature( sigMultiLine->text()); |
177 | } | 178 | } |
178 | } | 179 | } |
179 | void ComposeMail::saveAsDraft() | 180 | void ComposeMail::saveAsDraft() |
180 | { | 181 | { |
181 | 182 | ||
182 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 183 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
183 | mail->setMail(fromBox->currentText()); | 184 | mail->setMail(fromBox->currentText()); |
184 | mail->setTo( toLine->text() ); | 185 | mail->setTo( toLine->text() ); |
185 | mail->setName(senderNameEdit->text()); | 186 | mail->setName(senderNameEdit->text()); |
186 | mail->setCC( ccLine->text() ); | 187 | mail->setCC( ccLine->text() ); |
187 | mail->setBCC( bccLine->text() ); | 188 | mail->setBCC( bccLine->text() ); |
188 | mail->setReply( replyLine->text() ); | 189 | mail->setReply( replyLine->text() ); |
189 | mail->setSubject( subjectLine->text() ); | 190 | mail->setSubject( subjectLine->text() ); |
190 | if (!m_replyid.isEmpty()) { | 191 | if (!m_replyid.isEmpty()) { |
191 | QStringList ids; | 192 | QStringList ids; |
192 | ids.append(m_replyid); | 193 | ids.append(m_replyid); |
193 | mail->setInreply(ids); | 194 | mail->setInreply(ids); |
194 | } | 195 | } |
195 | QString txt = message->text(); | 196 | QString txt = message->text(); |
196 | if ( !sigMultiLine->text().isEmpty() ) { | 197 | if ( !sigMultiLine->text().isEmpty() ) { |
197 | txt.append( "\n--\n" ); | 198 | txt.append( "\n--\n" ); |
198 | txt.append( sigMultiLine->text() ); | 199 | txt.append( sigMultiLine->text() ); |
199 | } | 200 | } |
200 | mail->setMessage( txt ); | 201 | mail->setMessage( txt ); |
201 | mail->setCharset (mEncoding); | 202 | mail->setCharset (mEncoding); |
202 | /* only use the default drafts folder name! */ | 203 | /* only use the default drafts folder name! */ |
203 | Storemail wrapper(AbstractMail::draftFolder()); | 204 | Storemail wrapper(AbstractMail::draftFolder()); |
204 | wrapper.storeMail(mail); | 205 | wrapper.storeMail(mail); |
205 | 206 | ||
206 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 207 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
207 | /* attachments we will ignore! */ | 208 | /* attachments we will ignore! */ |
208 | if ( it != 0 ) { | 209 | if ( it != 0 ) { |
209 | if ( warnAttach ) | 210 | if ( warnAttach ) |
210 | QMessageBox::warning(0,i18n("Store message"), | 211 | QMessageBox::warning(0,i18n("Store message"), |
211 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 212 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
212 | warnAttach = false; | 213 | warnAttach = false; |
213 | } | 214 | } |
214 | setStatus( i18n("Mail saved as draft!") ); | 215 | setStatus( i18n("Mail saved as draft!") ); |
215 | } | 216 | } |
216 | void ComposeMail::clearStatus() | 217 | void ComposeMail::clearStatus() |
217 | { | 218 | { |
218 | topLevelWidget()->setCaption( i18n("Compose mail") ); | 219 | topLevelWidget()->setCaption( i18n("Compose mail") ); |
219 | } | 220 | } |
220 | void ComposeMail::setStatus( QString status ) | 221 | void ComposeMail::setStatus( QString status ) |
221 | { | 222 | { |
222 | topLevelWidget()->setCaption( status ); | 223 | topLevelWidget()->setCaption( status ); |
223 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; | 224 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; |
224 | } | 225 | } |
225 | void ComposeMail::pickAddress( ) | 226 | void ComposeMail::pickAddress( ) |
226 | { | 227 | { |
227 | 228 | ||
228 | QLineEdit *line = mPickLineEdit; | 229 | QLineEdit *line = mPickLineEdit; |
229 | if ( line == 0 ) | 230 | if ( line == 0 ) |
230 | return; | 231 | return; |
231 | #ifdef DESKTOP_VERSION | 232 | #ifdef DESKTOP_VERSION |
232 | //qDebug(" ComposeMail::pickAddress "); | 233 | //qDebug(" ComposeMail::pickAddress "); |
233 | QString names ;//= AddressPicker::getNames(); | 234 | QString names ;//= AddressPicker::getNames(); |
234 | 235 | ||
235 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 236 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
236 | uint i=0; | 237 | uint i=0; |
237 | for (i=0; i < list.count(); i++) { | 238 | for (i=0; i < list.count(); i++) { |
238 | if ( !list[i].preferredEmail().isEmpty()) { | 239 | if ( !list[i].preferredEmail().isEmpty()) { |
239 | if ( ! names.isEmpty() ) | 240 | if ( ! names.isEmpty() ) |
240 | names+= ","; | 241 | names+= ","; |
241 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 242 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; |
242 | 243 | ||
243 | } | 244 | } |
244 | } | 245 | } |
245 | 246 | ||
246 | 247 | ||
247 | if ( line->text().isEmpty() ) { | 248 | if ( line->text().isEmpty() ) { |
248 | line->setText( names ); | 249 | line->setText( names ); |
249 | } else if ( !names.isEmpty() ) { | 250 | } else if ( !names.isEmpty() ) { |
250 | line->setText( line->text() + ", " + names ); | 251 | line->setText( line->text() + ", " + names ); |
251 | } | 252 | } |
252 | #else | 253 | #else |
253 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | 254 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); |
254 | // the result should now arrive through method insertAttendees | 255 | // the result should now arrive through method insertAttendees |
255 | #endif | 256 | #endif |
256 | } | 257 | } |
257 | //the map includes name/email pairs, that comes from Ka/Pi | 258 | //the map includes name/email pairs, that comes from Ka/Pi |
258 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 259 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
259 | { | 260 | { |
260 | //qDebug("ComposeMail::insertAttendees "); | 261 | //qDebug("ComposeMail::insertAttendees "); |
261 | raise(); | 262 | raise(); |
262 | 263 | ||
264 | QString UID = uid; | ||
265 | if ( uid.left( 18 ) == (this->name() +QString("pick2")) ) { | ||
266 | mPickLineEdit = toLine; | ||
267 | UID = this->name(); | ||
268 | subjectLine->setText( uid.mid( 18 ) ); | ||
269 | } | ||
270 | //qDebug("ccc %s %s ", uid.latin1(), this->name()); | ||
263 | if ( mPickLineEdit == 0 ) { //whoami received | 271 | if ( mPickLineEdit == 0 ) { //whoami received |
264 | QString defmail = uidList[0]; | 272 | QString defmail = uidList[0]; |
265 | if ( emailList.count() == 0 ) | 273 | if ( emailList.count() == 0 ) |
266 | QMessageBox::information( 0, i18n( "Hint" ), | 274 | QMessageBox::information( 0, i18n( "Hint" ), |
267 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 275 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
268 | i18n( "Ok" ) ); | 276 | i18n( "Ok" ) ); |
269 | if (defmail.length()!=0) { | 277 | if (defmail.length()!=0) { |
270 | fromBox->insertItem(defmail); | 278 | fromBox->insertItem(defmail); |
271 | } | 279 | } |
272 | QStringList::ConstIterator sit = emailList.begin(); | 280 | QStringList::ConstIterator sit = emailList.begin(); |
273 | int pref = 0; | 281 | int pref = 0; |
274 | for (;sit!=emailList.end();++sit) { | 282 | for (;sit!=emailList.end();++sit) { |
275 | if ( (*sit)==defmail) | 283 | if ( (*sit)==defmail) |
276 | continue; | 284 | continue; |
277 | fromBox->insertItem((*sit)); | 285 | fromBox->insertItem((*sit)); |
278 | } | 286 | } |
279 | senderNameEdit->setText(nameList[0]); | 287 | senderNameEdit->setText(nameList[0]); |
280 | return; | 288 | return; |
281 | } | 289 | } |
282 | QString names ; | 290 | QString names ; |
283 | QLineEdit *line = mPickLineEdit; | 291 | QLineEdit *line = mPickLineEdit; |
284 | if (uid == this->name()) | 292 | if (UID == this->name()) |
285 | { | 293 | { |
286 | for ( int i = 0; i < nameList.count(); i++) | 294 | for ( int i = 0; i < nameList.count(); i++) |
287 | { | 295 | { |
288 | QString _name = nameList[i]; | 296 | QString _name = nameList[i]; |
289 | QString _email = emailList[i]; | 297 | QString _email = emailList[i]; |
290 | QString _uid = uidList[i]; | 298 | QString _uid = uidList[i]; |
291 | if ( ! _email.isEmpty() ) { | 299 | if ( ! _email.isEmpty() ) { |
292 | if ( ! names.isEmpty() ) | 300 | if ( ! names.isEmpty() ) |
293 | names+= ","; | 301 | names+= ","; |
294 | names+= "\""+_name +"\"<" +_email +">"; | 302 | names+= "\""+_name +"\"<" +_email +">"; |
295 | } | 303 | } |
296 | } | 304 | } |
297 | } | 305 | } |
298 | if ( line->text().isEmpty() ) { | 306 | if ( line->text().isEmpty() ) { |
299 | line->setText( names ); | 307 | line->setText( names ); |
300 | } else if ( !names.isEmpty() ) { | 308 | } else if ( !names.isEmpty() ) { |
301 | line->setText( line->text() + ", " + names ); | 309 | line->setText( line->text() + ", " + names ); |
302 | } | 310 | } |
303 | } | 311 | } |
304 | 312 | ||
305 | void ComposeMail::setTo( const QString & to ) | 313 | void ComposeMail::setTo( const QString & to ) |
306 | { | 314 | { |
307 | toLine->setText( to ); | 315 | toLine->setText( to ); |
308 | } | 316 | } |
309 | 317 | ||
310 | void ComposeMail::setSubject( const QString & subject ) | 318 | void ComposeMail::setSubject( const QString & subject ) |
311 | { | 319 | { |
312 | subjectLine->setText( subject ); | 320 | subjectLine->setText( subject ); |
313 | } | 321 | } |
314 | 322 | ||
315 | void ComposeMail::setInReplyTo( const QString & messageId ) | 323 | void ComposeMail::setInReplyTo( const QString & messageId ) |
316 | { | 324 | { |
317 | m_replyid = messageId; | 325 | m_replyid = messageId; |
318 | } | 326 | } |
319 | 327 | ||
320 | void ComposeMail::setMessage( const QString & text ) | 328 | void ComposeMail::setMessage( const QString & text ) |
321 | { | 329 | { |
322 | message->setText( text ); | 330 | message->setText( text ); |
323 | } | 331 | } |
324 | 332 | ||
325 | 333 | ||
326 | void ComposeMail::pickAddressTo() | 334 | void ComposeMail::pickAddressTo() |
327 | { | 335 | { |
328 | mPickLineEdit = toLine; | 336 | mPickLineEdit = toLine; |
329 | pickAddress( ); | 337 | pickAddress( ); |
330 | } | 338 | } |
331 | 339 | ||
332 | void ComposeMail::pickAddressCC() | 340 | void ComposeMail::pickAddressCC() |
333 | { | 341 | { |
334 | mPickLineEdit = ccLine; | 342 | mPickLineEdit = ccLine; |
335 | pickAddress( ); | 343 | pickAddress( ); |
336 | } | 344 | } |
337 | 345 | ||
338 | void ComposeMail::pickAddressBCC() | 346 | void ComposeMail::pickAddressBCC() |
339 | { | 347 | { |
340 | mPickLineEdit = bccLine; | 348 | mPickLineEdit = bccLine; |
341 | pickAddress( ); | 349 | pickAddress( ); |
342 | } | 350 | } |
343 | 351 | ||
344 | void ComposeMail::pickAddressReply() | 352 | void ComposeMail::pickAddressReply() |
345 | { | 353 | { |
346 | mPickLineEdit = replyLine; | 354 | mPickLineEdit = replyLine; |
347 | pickAddress( ); | 355 | pickAddress( ); |
348 | } | 356 | } |
349 | 357 | ||
350 | void ComposeMail::fillValues( int current ) | 358 | void ComposeMail::fillValues( int current ) |
351 | { | 359 | { |
352 | #if 0 | 360 | #if 0 |
353 | SMTPaccount *smtp = smtpAccounts.at( current ); | 361 | SMTPaccount *smtp = smtpAccounts.at( current ); |
354 | ccLine->clear(); | 362 | ccLine->clear(); |
355 | if ( smtp->getUseCC() ) { | 363 | if ( smtp->getUseCC() ) { |
356 | ccLine->setText( smtp->getCC() ); | 364 | ccLine->setText( smtp->getCC() ); |
357 | } | 365 | } |
358 | bccLine->clear(); | 366 | bccLine->clear(); |
359 | if ( smtp->getUseBCC() ) { | 367 | if ( smtp->getUseBCC() ) { |
360 | bccLine->setText( smtp->getBCC() ); | 368 | bccLine->setText( smtp->getBCC() ); |
361 | } | 369 | } |
362 | replyLine->clear(); | 370 | replyLine->clear(); |
363 | if ( smtp->getUseReply() ) { | 371 | if ( smtp->getUseReply() ) { |
364 | replyLine->setText( smtp->getReply() ); | 372 | replyLine->setText( smtp->getReply() ); |
365 | } | 373 | } |
366 | #endif | 374 | #endif |
367 | SMTPaccount *smtp = smtpAccounts.at( current ); | 375 | SMTPaccount *smtp = smtpAccounts.at( current ); |
368 | if ( smtp ) | 376 | if ( smtp ) |
369 | sigMultiLine->setText( smtp->getSignature() ); | 377 | sigMultiLine->setText( smtp->getSignature() ); |
370 | } | 378 | } |
371 | 379 | ||
372 | void ComposeMail::slotAdjustColumns() | 380 | void ComposeMail::slotAdjustColumns() |
373 | { | 381 | { |
374 | int currPage = tabWidget->currentPageIndex(); | 382 | int currPage = tabWidget->currentPageIndex(); |
375 | 383 | ||
376 | tabWidget->showPage( attachTab ); | 384 | tabWidget->showPage( attachTab ); |
377 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 385 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
378 | attList->setColumnWidth( 1, 80 ); | 386 | attList->setColumnWidth( 1, 80 ); |
379 | 387 | ||
380 | tabWidget->setCurrentPage( currPage ); | 388 | tabWidget->setCurrentPage( currPage ); |
381 | } | 389 | } |
382 | 390 | ||
383 | void ComposeMail::addAttachment() | 391 | void ComposeMail::addAttachment() |
384 | { | 392 | { |
385 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); | 393 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); |
386 | if ( !lnk.isEmpty() ) { | 394 | if ( !lnk.isEmpty() ) { |
387 | Attachment *att = new Attachment( lnk ); | 395 | Attachment *att = new Attachment( lnk ); |
388 | (void) new AttachViewItem( attList, att ); | 396 | (void) new AttachViewItem( attList, att ); |
389 | } | 397 | } |
390 | } | 398 | } |
391 | 399 | ||
392 | void ComposeMail::removeAttachment() | 400 | void ComposeMail::removeAttachment() |
393 | { | 401 | { |
394 | if ( !attList->currentItem() ) { | 402 | if ( !attList->currentItem() ) { |
395 | QMessageBox::information( this, i18n( "Error" ), | 403 | QMessageBox::information( this, i18n( "Error" ), |
396 | i18n( "<p>Please select a File.</p>" ), | 404 | i18n( "<p>Please select a File.</p>" ), |
397 | i18n( "Ok" ) ); | 405 | i18n( "Ok" ) ); |
398 | } else { | 406 | } else { |
399 | attList->takeItem( attList->currentItem() ); | 407 | attList->takeItem( attList->currentItem() ); |
400 | } | 408 | } |
401 | } | 409 | } |
402 | 410 | ||
403 | void ComposeMail::accept() | 411 | void ComposeMail::accept() |
404 | { | 412 | { |
405 | if ( smtpAccountBox->count() == 0 ) { | 413 | if ( smtpAccountBox->count() == 0 ) { |
406 | 414 | ||
407 | reject(); | 415 | reject(); |
408 | return; | 416 | return; |
409 | } | 417 | } |
410 | 418 | ||
411 | if (! checkBoxLater->isChecked() ) { | 419 | if (! checkBoxLater->isChecked() ) { |
412 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), | 420 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), |
413 | i18n("Send this message?"), | 421 | i18n("Send this message?"), |
414 | i18n("Yes"), | 422 | i18n("Yes"), |
415 | i18n("Cancel")); | 423 | i18n("Cancel")); |
416 | 424 | ||
417 | if (yesno == 1) { | 425 | if (yesno == 1) { |
418 | return; | 426 | return; |
419 | } | 427 | } |
420 | } | 428 | } |
421 | #if 0 | 429 | #if 0 |
422 | odebug << "Sending Mail with " | 430 | odebug << "Sending Mail with " |
423 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; | 431 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; |
424 | #endif | 432 | #endif |
425 | Opie::Core::OSmartPointer<Mail> mail=new Mail; | 433 | Opie::Core::OSmartPointer<Mail> mail=new Mail; |
426 | 434 | ||
427 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 435 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
428 | mail->setMail(fromBox->currentText()); | 436 | mail->setMail(fromBox->currentText()); |
429 | 437 | ||
430 | if ( !toLine->text().isEmpty() ) { | 438 | if ( !toLine->text().isEmpty() ) { |
431 | mail->setTo( toLine->text() ); | 439 | mail->setTo( toLine->text() ); |
432 | } else { | 440 | } else { |
433 | QMessageBox::warning(0,i18n("Sending mail"), | 441 | QMessageBox::warning(0,i18n("Sending mail"), |
434 | i18n("No Receiver spezified" ) ); | 442 | i18n("No Receiver spezified" ) ); |
435 | return; | 443 | return; |
436 | } | 444 | } |
437 | 445 | ||
438 | mail->setName(senderNameEdit->text()); | 446 | mail->setName(senderNameEdit->text()); |
439 | mail->setCC( ccLine->text() ); | 447 | mail->setCC( ccLine->text() ); |
440 | mail->setBCC( bccLine->text() ); | 448 | mail->setBCC( bccLine->text() ); |
441 | mail->setReply( replyLine->text() ); | 449 | mail->setReply( replyLine->text() ); |
442 | mail->setSubject( subjectLine->text() ); | 450 | mail->setSubject( subjectLine->text() ); |
443 | if (!m_replyid.isEmpty()) { | 451 | if (!m_replyid.isEmpty()) { |
444 | QStringList ids; | 452 | QStringList ids; |
445 | ids.append(m_replyid); | 453 | ids.append(m_replyid); |
446 | mail->setInreply(ids); | 454 | mail->setInreply(ids); |
447 | } | 455 | } |
448 | QString txt = message->text(); | 456 | QString txt = message->text(); |
449 | if ( !sigMultiLine->text().isEmpty() ) { | 457 | if ( !sigMultiLine->text().isEmpty() ) { |
450 | txt.append( "\n--\n" ); | 458 | txt.append( "\n--\n" ); |
451 | txt.append( sigMultiLine->text() ); | 459 | txt.append( sigMultiLine->text() ); |
452 | } | 460 | } |
453 | mail->setMessage( txt ); | 461 | mail->setMessage( txt ); |
454 | mail->setCharset (mEncoding); | 462 | mail->setCharset (mEncoding); |
455 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 463 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
456 | while ( it != 0 ) { | 464 | while ( it != 0 ) { |
457 | mail->addAttachment( it->getAttachment() ); | 465 | mail->addAttachment( it->getAttachment() ); |
458 | it = (AttachViewItem *) it->nextSibling(); | 466 | it = (AttachViewItem *) it->nextSibling(); |
459 | } | 467 | } |
460 | 468 | ||
461 | SMTPwrapper wrapper( smtp ); | 469 | SMTPwrapper wrapper( smtp ); |
462 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) | 470 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) |
463 | setStatus( tr ("Mail sent")); | 471 | setStatus( tr ("Mail sent")); |
464 | else { | 472 | else { |
465 | setStatus( tr ("Error: Something went wrong. Nothing sent")); | 473 | setStatus( tr ("Error: Something went wrong. Nothing sent")); |
466 | return; | 474 | return; |
467 | } | 475 | } |
468 | 476 | ||
469 | 477 | ||
470 | QDialog::accept(); | 478 | QDialog::accept(); |
471 | } | 479 | } |
472 | 480 | ||
473 | void ComposeMail::reject() | 481 | void ComposeMail::reject() |
474 | { | 482 | { |
475 | //qDebug("ComposeMail::reject() "); | 483 | //qDebug("ComposeMail::reject() "); |
476 | int yesno = QMessageBox::warning(0,i18n("Store message?"), | 484 | int yesno = QMessageBox::warning(0,i18n("Store message?"), |
477 | i18n("Store message into drafts?\n"), | 485 | i18n("Store message into drafts?\n"), |
478 | i18n("Yes"), | 486 | i18n("Yes"), |
479 | i18n("No")); | 487 | i18n("No")); |
480 | 488 | ||
481 | //qDebug("button %d ", yesno); | 489 | //qDebug("button %d ", yesno); |
482 | if (yesno == 0) { | 490 | if (yesno == 0) { |
483 | if ( toLine->text().isEmpty() ) { | 491 | if ( toLine->text().isEmpty() ) { |
484 | QMessageBox::warning(0,i18n("Sending mail"), | 492 | QMessageBox::warning(0,i18n("Sending mail"), |
485 | i18n("No Receiver spezified" ) ); | 493 | i18n("No Receiver spezified" ) ); |
486 | return; | 494 | return; |
487 | } | 495 | } |
488 | saveAsDraft(); | 496 | saveAsDraft(); |
489 | } | 497 | } |
490 | if (yesno == 2) { | 498 | if (yesno == 2) { |
491 | qDebug("return "); | 499 | qDebug("return "); |
492 | return; | 500 | return; |
493 | } | 501 | } |
494 | QDialog::reject(); | 502 | QDialog::reject(); |
495 | } | 503 | } |
496 | 504 | ||
497 | void ComposeMail::setCharset(const QString& charset) | 505 | void ComposeMail::setCharset(const QString& charset) |
498 | { | 506 | { |
499 | if ( !charset.isEmpty() ) | 507 | if ( !charset.isEmpty() ) |
500 | mEncoding = charset; | 508 | mEncoding = charset; |
501 | qDebug("ComposeMail::setCharset %s ", mEncoding.latin1()); | 509 | qDebug("ComposeMail::setCharset %s ", mEncoding.latin1()); |
502 | } | 510 | } |
503 | ComposeMail::~ComposeMail() | 511 | ComposeMail::~ComposeMail() |
504 | { | 512 | { |
505 | } | 513 | } |
506 | 514 | ||
507 | void ComposeMail::reEditMail(const RecMailP¤t) | 515 | void ComposeMail::reEditMail(const RecMailP¤t) |
508 | { | 516 | { |
509 | RecMailP data = current; | 517 | RecMailP data = current; |
510 | RecBodyP body = data->Wrapper()->fetchBody(current); | 518 | RecBodyP body = data->Wrapper()->fetchBody(current); |
511 | 519 | ||
512 | message->setText(body->Bodytext()); | 520 | message->setText(body->Bodytext()); |
513 | subjectLine->setText( data->getSubject()); | 521 | subjectLine->setText( data->getSubject()); |
514 | toLine->setText(data->To().join(",")); | 522 | toLine->setText(data->To().join(",")); |
515 | ccLine->setText(data->CC().join(",")); | 523 | ccLine->setText(data->CC().join(",")); |
516 | bccLine->setText(data->Bcc().join(",")); | 524 | bccLine->setText(data->Bcc().join(",")); |
517 | replyLine->setText(data->Replyto()); | 525 | replyLine->setText(data->Replyto()); |
518 | setCharset(body->getCharset()); | 526 | setCharset(body->getCharset()); |
519 | } | 527 | } |
520 | 528 | ||
521 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 529 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
522 | : QListViewItem( parent ) | 530 | : QListViewItem( parent ) |
523 | { | 531 | { |
524 | attachment = att; | 532 | attachment = att; |
525 | if ( !attachment->getPixmap().isNull() ) | 533 | if ( !attachment->getPixmap().isNull() ) |
526 | setPixmap( 0,attachment->getPixmap() ); | 534 | setPixmap( 0,attachment->getPixmap() ); |
527 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 535 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
528 | setText( 1, QString::number( att->getSize() ) ); | 536 | setText( 1, QString::number( att->getSize() ) ); |
529 | } | 537 | } |
530 | 538 | ||
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index f56711d..e159b73 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,641 +1,672 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | 4 | ||
5 | #define protected public | 5 | #define protected public |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #undef protected | 7 | #undef protected |
8 | #include "koprefsdialog.h" | 8 | #include "koprefsdialog.h" |
9 | #include <kapplication.h> | 9 | #include <kapplication.h> |
10 | #include <libkdepim/externalapphandler.h> | 10 | #include <libkdepim/externalapphandler.h> |
11 | #include <libkdepim/kpimglobalprefs.h> | 11 | #include <libkdepim/kpimglobalprefs.h> |
12 | #ifdef MINIKDE_KDIALOG_H | 12 | #ifdef MINIKDE_KDIALOG_H |
13 | #undef MINIKDE_KDIALOG_H | 13 | #undef MINIKDE_KDIALOG_H |
14 | #endif | 14 | #endif |
15 | #include "settingsdialog.h" | 15 | #include "settingsdialog.h" |
16 | #include "opiemail.h" | 16 | #include "opiemail.h" |
17 | #include "editaccounts.h" | 17 | #include "editaccounts.h" |
18 | #include "composemail.h" | 18 | #include "composemail.h" |
19 | #include "mailistviewitem.h" | 19 | #include "mailistviewitem.h" |
20 | #include "viewmail.h" | 20 | #include "viewmail.h" |
21 | #include "selectstore.h" | 21 | #include "selectstore.h" |
22 | #include "selectsmtp.h" | 22 | #include "selectsmtp.h" |
23 | #include "accountitem.h" | 23 | #include "accountitem.h" |
24 | #include "accountview.h" | 24 | #include "accountview.h" |
25 | #include "klocale.h" | 25 | #include "klocale.h" |
26 | 26 | ||
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qcursor.h> | 29 | #include <qcursor.h> |
30 | #include <qtextbrowser.h> | 30 | #include <qtextbrowser.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | 33 | ||
34 | #ifdef DESKTOP_VERSION | 34 | #ifdef DESKTOP_VERSION |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #else | 36 | #else |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #endif | 38 | #endif |
39 | #include <libmailwrapper/smtpwrapper.h> | 39 | #include <libmailwrapper/smtpwrapper.h> |
40 | #include <libmailwrapper/mailtypes.h> | 40 | #include <libmailwrapper/mailtypes.h> |
41 | #include <libmailwrapper/abstractmail.h> | 41 | #include <libmailwrapper/abstractmail.h> |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | 43 | ||
44 | //using namespace Opie::Core; | 44 | //using namespace Opie::Core; |
45 | 45 | ||
46 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 46 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
48 | { | 48 | { |
49 | mCurrentComposer = 0; | ||
49 | settings = new Settings(); | 50 | settings = new Settings(); |
50 | tb = 0; | 51 | tb = 0; |
51 | setIcon(SmallIcon( "kmicromail" ) ); | 52 | setIcon(SmallIcon( "kmicromail" ) ); |
52 | folderView->populate( settings->getAccounts() ); | 53 | folderView->populate( settings->getAccounts() ); |
53 | 54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | |
55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | ||
54 | } | 56 | } |
55 | 57 | ||
56 | OpieMail::~OpieMail() | 58 | OpieMail::~OpieMail() |
57 | { | 59 | { |
58 | if (settings) delete settings; | 60 | if (settings) delete settings; |
59 | if ( tb ) | 61 | if ( tb ) |
60 | delete tb; | 62 | delete tb; |
61 | } | 63 | } |
62 | 64 | ||
63 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
64 | { | 66 | { |
65 | 67 | ||
66 | } | 68 | } |
67 | #include <stdlib.h> | 69 | #include <stdlib.h> |
68 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 70 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
69 | { | 71 | { |
70 | // copied from old mail2 | 72 | // copied from old mail2 |
71 | static int ii = 0; | 73 | static int ii = 0; |
72 | //qDebug("QCOP CALL ############################# %d ", ii); | 74 | //qDebug("QCOP CALL ############################# %d ", ii); |
73 | //QString mess ( msg ); | 75 | //QString mess ( msg ); |
74 | //qDebug("Message = %s ",mess.latin1()); | 76 | //qDebug("Message = %s ",mess.latin1()); |
75 | ++ii; | 77 | ++ii; |
76 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
77 | 79 | ||
78 | mPendingEmail = QString::null; | 80 | mPendingEmail = QString::null; |
79 | mPendingName = QString::null; | 81 | mPendingName = QString::null; |
80 | if (msg == "writeMail(QString,QString)") | 82 | if (msg == "writeMail(QString,QString)") |
81 | { | 83 | { |
82 | //qDebug("writeMail(QString,QString) "); | 84 | //qDebug("writeMail(QString,QString) "); |
83 | QDataStream stream(data,IO_ReadOnly); | 85 | QDataStream stream(data,IO_ReadOnly); |
84 | stream >> mPendingName >> mPendingEmail; | 86 | stream >> mPendingName >> mPendingEmail; |
85 | // removing the whitespaces at beginning and end is needed! | 87 | // removing the whitespaces at beginning and end is needed! |
86 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
87 | } | 89 | } |
88 | else if (msg == "newMail()") | 90 | else if (msg == "newMail()") |
89 | { | 91 | { |
90 | //qDebug("slotComposeMail() "); | 92 | //qDebug("slotComposeMail() "); |
91 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 93 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
92 | // and a QCOP call does not like a processevents in his execution | 94 | // and a QCOP call does not like a processevents in his execution |
93 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 95 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
94 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
95 | // slotComposeMail(); | 97 | // slotComposeMail(); |
96 | } | 98 | } |
97 | else if (msg == "newMail(QString)") | 99 | else if (msg == "newMail(QString)") |
98 | { | 100 | { |
99 | //qDebug(" newMail(QString)"); | 101 | //qDebug(" newMail(QString)"); |
100 | QDataStream stream(data,IO_ReadOnly); | 102 | QDataStream stream(data,IO_ReadOnly); |
101 | stream >> mPendingName; | 103 | stream >> mPendingName; |
102 | // the format is | 104 | // the format is |
103 | // NAME <EMAIL>:SUBJECT | 105 | // NAME <EMAIL>:SUBJECT |
104 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
105 | } else { | 107 | } else { |
106 | mPendingData = data; | 108 | mPendingData = data; |
107 | mPendingMessage = msg; | 109 | mPendingMessage = msg; |
108 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
109 | } | 111 | } |
110 | 112 | ||
111 | //qDebug("END OpieMail::message "); | 113 | //qDebug("END OpieMail::message "); |
112 | } | 114 | } |
113 | void OpieMail::slotExtAppHandler() | 115 | void OpieMail::slotExtAppHandler() |
114 | { | 116 | { |
115 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
116 | } | 118 | } |
117 | void OpieMail::slotwriteMail2(const QString& namemail ) | 119 | void OpieMail::slotwriteMail2(const QString& namemail ) |
118 | { | 120 | { |
119 | //qDebug("OpieMail::slotwriteMail2 "); | 121 | //qDebug("OpieMail::slotwriteMail2 "); |
120 | //qApp->processEvents(); | 122 | //qApp->processEvents(); |
121 | ComposeMail compose( settings, this, 0, true ); | 123 | ComposeMail compose( settings, this, 0, true ); |
122 | if ( !namemail.isEmpty() ) { | 124 | if ( !namemail.isEmpty() ) { |
123 | QString to = namemail; | 125 | QString to = namemail; |
124 | if ( namemail.find( " <") > 1 ) { | 126 | if ( namemail.find( " <") > 1 ) { |
125 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
126 | } else | 128 | } else |
127 | if ( namemail.find( "<") > 1 ) { | 129 | if ( namemail.find( "<") > 1 ) { |
128 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
129 | } | 131 | } |
130 | int sub = to.find( ">:"); | 132 | int sub = to.find( ">:"); |
131 | if ( sub > 0 ) { | 133 | if ( sub > 0 ) { |
132 | compose.setTo( to.left(sub+1) ); | 134 | compose.setTo( to.left(sub+1) ); |
133 | compose.setSubject( to.mid(sub+2) ); | 135 | compose.setSubject( to.mid(sub+2) ); |
134 | } else | 136 | } else |
135 | compose.setTo( to ); | 137 | compose.setTo( to ); |
136 | } | 138 | } |
137 | compose.slotAdjustColumns(); | 139 | compose.slotAdjustColumns(); |
138 | #ifndef DESKTOP_VERSION | 140 | #ifndef DESKTOP_VERSION |
139 | compose.showMaximized(); | 141 | compose.showMaximized(); |
140 | #endif | 142 | #endif |
143 | mCurrentComposer = &compose; | ||
141 | compose.exec(); | 144 | compose.exec(); |
145 | mCurrentComposer = 0; | ||
142 | raise(); | 146 | raise(); |
143 | //qDebug("retttich "); | 147 | //qDebug("retttich "); |
144 | } | 148 | } |
145 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 149 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
146 | { | 150 | { |
147 | // qDebug("OpieMail::slotwriteMail "); | 151 | // qDebug("OpieMail::slotwriteMail "); |
148 | ComposeMail compose( settings, this, 0, true ); | 152 | ComposeMail compose( settings, this, 0, true ); |
149 | if (!email.isEmpty()) | 153 | if (!email.isEmpty()) |
150 | { | 154 | { |
151 | if (!name.isEmpty()) | 155 | if (!name.isEmpty()) |
152 | { | 156 | { |
153 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 157 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
154 | } | 158 | } |
155 | else | 159 | else |
156 | { | 160 | { |
157 | compose.setTo(email); | 161 | compose.setTo(email); |
158 | } | 162 | } |
159 | } | 163 | } |
160 | compose.slotAdjustColumns(); | 164 | compose.slotAdjustColumns(); |
161 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
162 | compose.showMaximized(); | 166 | compose.showMaximized(); |
163 | #endif | 167 | #endif |
168 | |||
169 | mCurrentComposer = &compose; | ||
164 | compose.exec(); | 170 | compose.exec(); |
171 | mCurrentComposer = 0; | ||
165 | raise(); | 172 | raise(); |
166 | } | 173 | } |
167 | 174 | ||
168 | void OpieMail::slotComposeMail() | 175 | void OpieMail::slotComposeMail() |
169 | { | 176 | { |
170 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 177 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
171 | slotwriteMail2( QString () ); | 178 | slotwriteMail2( QString () ); |
172 | else { | 179 | else { |
173 | if ( mPendingEmail == QString::null ) | 180 | if ( mPendingEmail == QString::null ) |
174 | slotwriteMail2( mPendingName ); | 181 | slotwriteMail2( mPendingName ); |
175 | else | 182 | else |
176 | slotwriteMail( mPendingName, mPendingEmail ); | 183 | slotwriteMail( mPendingName, mPendingEmail ); |
177 | } | 184 | } |
178 | //slotwriteMail(0l,0l); | 185 | //slotwriteMail(0l,0l); |
179 | } | 186 | } |
180 | 187 | ||
181 | void OpieMail::slotSendQueued() | 188 | void OpieMail::slotSendQueued() |
182 | { | 189 | { |
183 | SMTPaccount *smtp = 0; | 190 | SMTPaccount *smtp = 0; |
184 | 191 | ||
185 | QList<Account> list = settings->getAccounts(); | 192 | QList<Account> list = settings->getAccounts(); |
186 | QList<SMTPaccount> smtpList; | 193 | QList<SMTPaccount> smtpList; |
187 | smtpList.setAutoDelete(false); | 194 | smtpList.setAutoDelete(false); |
188 | Account *it; | 195 | Account *it; |
189 | for ( it = list.first(); it; it = list.next() ) | 196 | for ( it = list.first(); it; it = list.next() ) |
190 | { | 197 | { |
191 | if ( it->getType() == MAILLIB::A_SMTP ) | 198 | if ( it->getType() == MAILLIB::A_SMTP ) |
192 | { | 199 | { |
193 | smtp = static_cast<SMTPaccount *>(it); | 200 | smtp = static_cast<SMTPaccount *>(it); |
194 | smtpList.append(smtp); | 201 | smtpList.append(smtp); |
195 | } | 202 | } |
196 | } | 203 | } |
197 | if (smtpList.count()==0) | 204 | if (smtpList.count()==0) |
198 | { | 205 | { |
199 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 206 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
200 | return; | 207 | return; |
201 | } | 208 | } |
202 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 209 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
203 | return; | 210 | return; |
204 | if (smtpList.count()==1) | 211 | if (smtpList.count()==1) |
205 | { | 212 | { |
206 | smtp = smtpList.at(0); | 213 | smtp = smtpList.at(0); |
207 | } | 214 | } |
208 | else | 215 | else |
209 | { | 216 | { |
210 | smtp = 0; | 217 | smtp = 0; |
211 | selectsmtp selsmtp; | 218 | selectsmtp selsmtp; |
212 | selsmtp.setSelectionlist(&smtpList); | 219 | selsmtp.setSelectionlist(&smtpList); |
213 | #ifndef DESKTOP_VERSION | 220 | #ifndef DESKTOP_VERSION |
214 | selsmtp.showMaximized(); | 221 | selsmtp.showMaximized(); |
215 | #endif | 222 | #endif |
216 | if ( selsmtp.exec() == QDialog::Accepted ) | 223 | if ( selsmtp.exec() == QDialog::Accepted ) |
217 | { | 224 | { |
218 | smtp = selsmtp.selected_smtp(); | 225 | smtp = selsmtp.selected_smtp(); |
219 | } | 226 | } |
220 | } | 227 | } |
221 | if (smtp) | 228 | if (smtp) |
222 | { | 229 | { |
223 | 230 | ||
224 | Global::statusMessage("Sending mails...!"); | 231 | Global::statusMessage("Sending mails...!"); |
225 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 232 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
226 | if ( wrap->flushOutbox() ) | 233 | if ( wrap->flushOutbox() ) |
227 | { | 234 | { |
228 | Global::statusMessage("Mails sent!"); | 235 | Global::statusMessage("Mails sent!"); |
229 | } | 236 | } |
230 | delete wrap; | 237 | delete wrap; |
231 | } | 238 | } |
232 | // pending refresh list view, if outgoing is displayed | 239 | // pending refresh list view, if outgoing is displayed |
233 | } | 240 | } |
234 | 241 | ||
235 | void OpieMail::slotSearchMails() | 242 | void OpieMail::slotSearchMails() |
236 | { | 243 | { |
237 | qDebug("OpieMail::slotSearchMails():not implemented "); | 244 | qDebug("OpieMail::slotSearchMails():not implemented "); |
238 | } | 245 | } |
239 | 246 | ||
240 | void OpieMail::slotEditSettings() | 247 | void OpieMail::slotEditSettings() |
241 | { | 248 | { |
242 | 249 | ||
243 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 250 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
244 | #ifndef DESKTOP_VERSION | 251 | #ifndef DESKTOP_VERSION |
245 | settingsDialog.showMaximized(); | 252 | settingsDialog.showMaximized(); |
246 | #endif | 253 | #endif |
247 | settingsDialog.exec(); | 254 | settingsDialog.exec(); |
248 | 255 | ||
249 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 256 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
250 | // KApplication::execDialog(settingsDialog); | 257 | // KApplication::execDialog(settingsDialog); |
251 | } | 258 | } |
252 | 259 | ||
253 | void OpieMail::slotEditAccounts() | 260 | void OpieMail::slotEditAccounts() |
254 | { | 261 | { |
255 | EditAccounts eaDialog( settings, this, 0, true ); | 262 | EditAccounts eaDialog( settings, this, 0, true ); |
256 | eaDialog.slotAdjustColumns(); | 263 | eaDialog.slotAdjustColumns(); |
257 | #ifndef DESKTOP_VERSION | 264 | #ifndef DESKTOP_VERSION |
258 | eaDialog.showMaximized(); | 265 | eaDialog.showMaximized(); |
259 | #endif | 266 | #endif |
260 | eaDialog.exec(); | 267 | eaDialog.exec(); |
261 | if ( settings ) delete settings; | 268 | if ( settings ) delete settings; |
262 | settings = new Settings(); | 269 | settings = new Settings(); |
263 | 270 | ||
264 | folderView->populate( settings->getAccounts() ); | 271 | folderView->populate( settings->getAccounts() ); |
265 | } | 272 | } |
266 | void OpieMail::replyMail() | 273 | void OpieMail::replyMail() |
267 | { | 274 | { |
268 | 275 | ||
269 | QListViewItem*item = mailView->currentItem(); | 276 | QListViewItem*item = mailView->currentItem(); |
270 | if (!item) return; | 277 | if (!item) return; |
271 | RecMailP mail = ((MailListViewItem*)item)->data(); | 278 | RecMailP mail = ((MailListViewItem*)item)->data(); |
272 | RecBodyP body = folderView->fetchBody(mail); | 279 | RecBodyP body = folderView->fetchBody(mail); |
273 | 280 | ||
274 | QString rtext; | 281 | QString rtext; |
275 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 282 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
276 | .arg( mail->getFrom()) | 283 | .arg( mail->getFrom()) |
277 | .arg( mail->getDate()); | 284 | .arg( mail->getDate()); |
278 | 285 | ||
279 | QString text = body->Bodytext(); | 286 | QString text = body->Bodytext(); |
280 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 287 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
281 | QStringList::Iterator it; | 288 | QStringList::Iterator it; |
282 | for (it = lines.begin(); it != lines.end(); it++) | 289 | for (it = lines.begin(); it != lines.end(); it++) |
283 | { | 290 | { |
284 | rtext += "> " + *it + "\n"; | 291 | rtext += "> " + *it + "\n"; |
285 | } | 292 | } |
286 | rtext += "\n"; | 293 | rtext += "\n"; |
287 | 294 | ||
288 | QString prefix; | 295 | QString prefix; |
289 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 296 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
290 | else prefix = "Re: "; // no i18n on purpose | 297 | else prefix = "Re: "; // no i18n on purpose |
291 | 298 | ||
292 | Settings *settings = new Settings(); | 299 | Settings *settings = new Settings(); |
293 | ComposeMail composer( settings ,this, 0, true); | 300 | ComposeMail composer( settings ,this, 0, true); |
294 | if (mail->Replyto().isEmpty()) { | 301 | if (mail->Replyto().isEmpty()) { |
295 | composer.setTo( mail->getFrom()); | 302 | composer.setTo( mail->getFrom()); |
296 | } else { | 303 | } else { |
297 | composer.setTo( mail->Replyto()); | 304 | composer.setTo( mail->Replyto()); |
298 | } | 305 | } |
299 | composer.setSubject( prefix + mail->getSubject()); | 306 | composer.setSubject( prefix + mail->getSubject()); |
300 | composer.setMessage( rtext ); | 307 | composer.setMessage( rtext ); |
301 | composer.setInReplyTo( mail->Msgid()); | 308 | composer.setInReplyTo( mail->Msgid()); |
302 | composer.setCharset( body->getCharset() ); | 309 | composer.setCharset( body->getCharset() ); |
310 | |||
311 | mCurrentComposer = &composer; | ||
303 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 312 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
304 | { | 313 | { |
305 | mail->Wrapper()->answeredMail(mail); | 314 | mail->Wrapper()->answeredMail(mail); |
306 | } | 315 | } |
316 | mCurrentComposer = 0; | ||
307 | delete settings; | 317 | delete settings; |
308 | 318 | ||
309 | } | 319 | } |
310 | void OpieMail::closeViewMail(ViewMail * vm) | 320 | void OpieMail::closeViewMail(ViewMail * vm) |
311 | { | 321 | { |
312 | vm->hide(); | 322 | vm->hide(); |
313 | } | 323 | } |
314 | 324 | ||
315 | void OpieMail::slotDownloadMail( ) | 325 | void OpieMail::slotDownloadMail( ) |
316 | { | 326 | { |
317 | QListViewItem*item = mailView->currentItem(); | 327 | QListViewItem*item = mailView->currentItem(); |
318 | if (!item ) { | 328 | if (!item ) { |
319 | Global::statusMessage("Error: No item slected!"); | 329 | Global::statusMessage("Error: No item slected!"); |
320 | return; | 330 | return; |
321 | } | 331 | } |
322 | RecMailP mail = ((MailListViewItem*)item)->data(); | 332 | RecMailP mail = ((MailListViewItem*)item)->data(); |
323 | Account * acc = mail->Wrapper()->getAccount(); | 333 | Account * acc = mail->Wrapper()->getAccount(); |
324 | if ( !acc ) { | 334 | if ( !acc ) { |
325 | Global::statusMessage("Mail is already stored locally!"); | 335 | Global::statusMessage("Mail is already stored locally!"); |
326 | return; | 336 | return; |
327 | } | 337 | } |
328 | QString lfName = acc->getLocalFolder(); | 338 | QString lfName = acc->getLocalFolder(); |
329 | //qDebug("local folder " + lfName ); | 339 | //qDebug("local folder " + lfName ); |
330 | if ( lfName.isEmpty() ) | 340 | if ( lfName.isEmpty() ) |
331 | lfName = acc->getAccountName(); | 341 | lfName = acc->getAccountName(); |
332 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); | 342 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); |
333 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); | 343 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); |
334 | if ( targetMail == mail->Wrapper() ) { | 344 | if ( targetMail == mail->Wrapper() ) { |
335 | Global::statusMessage("Mail is already locally stored!"); | 345 | Global::statusMessage("Mail is already locally stored!"); |
336 | return; | 346 | return; |
337 | } | 347 | } |
338 | if ( !targetMail->createMbox(lfName)) { | 348 | if ( !targetMail->createMbox(lfName)) { |
339 | Global::statusMessage("Error creating folder!"); | 349 | Global::statusMessage("Error creating folder!"); |
340 | return; | 350 | return; |
341 | } | 351 | } |
342 | Global::statusMessage("Fetching mail...please wait!"); | 352 | Global::statusMessage("Fetching mail...please wait!"); |
343 | qApp->processEvents(); | 353 | qApp->processEvents(); |
344 | encodedString*st = 0; | 354 | encodedString*st = 0; |
345 | st = mail->Wrapper()->fetchRawBody(mail); | 355 | st = mail->Wrapper()->fetchRawBody(mail); |
346 | if ( st ) { | 356 | if ( st ) { |
347 | targetMail->storeMessage(st->Content(),st->Length(),lfName); | 357 | targetMail->storeMessage(st->Content(),st->Length(),lfName); |
348 | Global::statusMessage("Mail stored in "+ lfName); | 358 | Global::statusMessage("Mail stored in "+ lfName); |
349 | delete st; | 359 | delete st; |
350 | } else { | 360 | } else { |
351 | Global::statusMessage("Error: Cannot fetch mail!"); | 361 | Global::statusMessage("Error: Cannot fetch mail!"); |
352 | } | 362 | } |
353 | } | 363 | } |
354 | 364 | ||
355 | 365 | ||
356 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) | 366 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) |
357 | { | 367 | { |
358 | QListViewItem*item = mailView->currentItem(); | 368 | QListViewItem*item = mailView->currentItem(); |
359 | if (!item ) { | 369 | if (!item ) { |
360 | closeViewMail(vm); | 370 | closeViewMail(vm); |
361 | return; | 371 | return; |
362 | } | 372 | } |
363 | RecMailP mail = ((MailListViewItem*)item)->data(); | 373 | RecMailP mail = ((MailListViewItem*)item)->data(); |
364 | mail->Wrapper()->deleteMail( mail ); | 374 | mail->Wrapper()->deleteMail( mail ); |
365 | item = item->itemBelow(); | 375 | item = item->itemBelow(); |
366 | if (!item ) { | 376 | if (!item ) { |
367 | closeViewMail(vm); | 377 | closeViewMail(vm); |
368 | return; | 378 | return; |
369 | } | 379 | } |
370 | mailView->setCurrentItem(item); | 380 | mailView->setCurrentItem(item); |
371 | mail = ((MailListViewItem*)item)->data(); | 381 | mail = ((MailListViewItem*)item)->data(); |
372 | RecBodyP body = folderView->fetchBody(mail); | 382 | RecBodyP body = folderView->fetchBody(mail); |
373 | vm->setBody( body ); | 383 | vm->setBody( body ); |
374 | vm->setMail( mail ); | 384 | vm->setMail( mail ); |
375 | } | 385 | } |
376 | void OpieMail::displayNextMail(ViewMail * vm) | 386 | void OpieMail::displayNextMail(ViewMail * vm) |
377 | { | 387 | { |
378 | QListViewItem*item = mailView->currentItem(); | 388 | QListViewItem*item = mailView->currentItem(); |
379 | if (!item) return; | 389 | if (!item) return; |
380 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 390 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
381 | item = item->itemBelow(); | 391 | item = item->itemBelow(); |
382 | if (!item) { | 392 | if (!item) { |
383 | vm->setCaption(i18n("End of List" )); | 393 | vm->setCaption(i18n("End of List" )); |
384 | return; | 394 | return; |
385 | } | 395 | } |
386 | mailView->setCurrentItem(item); | 396 | mailView->setCurrentItem(item); |
387 | RecMailP mail = ((MailListViewItem*)item)->data(); | 397 | RecMailP mail = ((MailListViewItem*)item)->data(); |
388 | RecBodyP body = folderView->fetchBody(mail); | 398 | RecBodyP body = folderView->fetchBody(mail); |
389 | vm->setBody( body ); | 399 | vm->setBody( body ); |
390 | vm->setMail( mail ); | 400 | vm->setMail( mail ); |
391 | } | 401 | } |
392 | void OpieMail::displayMail() | 402 | void OpieMail::displayMail() |
393 | { | 403 | { |
394 | QListViewItem*item = mailView->currentItem(); | 404 | QListViewItem*item = mailView->currentItem(); |
395 | if (!item) return; | 405 | if (!item) return; |
396 | RecMailP mail = ((MailListViewItem*)item)->data(); | 406 | RecMailP mail = ((MailListViewItem*)item)->data(); |
397 | RecBodyP body = folderView->fetchBody(mail); | 407 | RecBodyP body = folderView->fetchBody(mail); |
398 | ViewMail readMail( this,"", Qt::WType_Modal ); | 408 | ViewMail readMail( this,"", Qt::WType_Modal ); |
399 | readMail.setBody( body ); | 409 | readMail.setBody( body ); |
400 | readMail.setMail( mail ); | 410 | readMail.setMail( mail ); |
401 | #ifndef DESKTOP_VERSION | 411 | #ifndef DESKTOP_VERSION |
402 | readMail.showMaximized(); | 412 | readMail.showMaximized(); |
403 | #else | 413 | #else |
404 | readMail.resize( 640, 480); | 414 | readMail.resize( 640, 480); |
405 | #endif | 415 | #endif |
406 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); | 416 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); |
407 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); | 417 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); |
408 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); | 418 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); |
409 | 419 | ||
410 | readMail.exec(); | 420 | readMail.exec(); |
411 | 421 | ||
412 | if ( readMail.deleted ) | 422 | if ( readMail.deleted ) |
413 | { | 423 | { |
414 | folderView->refreshCurrent(); | 424 | folderView->refreshCurrent(); |
415 | } | 425 | } |
416 | else | 426 | else |
417 | { | 427 | { |
418 | QListViewItem*item = mailView->currentItem(); | 428 | QListViewItem*item = mailView->currentItem(); |
419 | if (item) | 429 | if (item) |
420 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 430 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
421 | } | 431 | } |
422 | } | 432 | } |
423 | void OpieMail::slotGetAllMail() | 433 | void OpieMail::slotGetAllMail() |
424 | { | 434 | { |
425 | QListViewItem * item = folderView->firstChild(); | 435 | QListViewItem * item = folderView->firstChild(); |
426 | while ( item ){ | 436 | while ( item ){ |
427 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 437 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
428 | item = item->nextSibling (); | 438 | item = item->nextSibling (); |
429 | } | 439 | } |
430 | } | 440 | } |
431 | void OpieMail::slotGetMail() | 441 | void OpieMail::slotGetMail() |
432 | { | 442 | { |
433 | QListViewItem * item = folderView->currentItem(); | 443 | QListViewItem * item = folderView->currentItem(); |
434 | if ( ! item ) return; | 444 | if ( ! item ) return; |
435 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 445 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
436 | } | 446 | } |
437 | void OpieMail::slotDeleteMail() | 447 | void OpieMail::slotDeleteMail() |
438 | { | 448 | { |
439 | if (!mailView->currentItem()) return; | 449 | if (!mailView->currentItem()) return; |
440 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 450 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
441 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 451 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
442 | { | 452 | { |
443 | mail->Wrapper()->deleteMail( mail ); | 453 | mail->Wrapper()->deleteMail( mail ); |
444 | folderView->refreshCurrent(); | 454 | folderView->refreshCurrent(); |
445 | } | 455 | } |
446 | } | 456 | } |
447 | void OpieMail::slotDeleteAllMail() | 457 | void OpieMail::slotDeleteAllMail() |
448 | { | 458 | { |
449 | 459 | ||
450 | QValueList<RecMailP> t; | 460 | QValueList<RecMailP> t; |
451 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 461 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
452 | { | 462 | { |
453 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 463 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
454 | while ( item ) { | 464 | while ( item ) { |
455 | if ( item->isSelected() ) { | 465 | if ( item->isSelected() ) { |
456 | t.append( item->data() ); | 466 | t.append( item->data() ); |
457 | } | 467 | } |
458 | item = (MailListViewItem*)item->nextSibling(); | 468 | item = (MailListViewItem*)item->nextSibling(); |
459 | } | 469 | } |
460 | } | 470 | } |
461 | else | 471 | else |
462 | return; | 472 | return; |
463 | if ( t.count() == 0 ) | 473 | if ( t.count() == 0 ) |
464 | return; | 474 | return; |
465 | RecMailP mail = t.first(); | 475 | RecMailP mail = t.first(); |
466 | mail->Wrapper()->deleteMailList(t); | 476 | mail->Wrapper()->deleteMailList(t); |
467 | folderView->refreshCurrent(); | 477 | folderView->refreshCurrent(); |
468 | 478 | ||
469 | 479 | ||
470 | } | 480 | } |
471 | void OpieMail::clearSelection() | 481 | void OpieMail::clearSelection() |
472 | { | 482 | { |
473 | mailView->clearSelection(); | 483 | mailView->clearSelection(); |
474 | 484 | ||
475 | } | 485 | } |
476 | 486 | ||
477 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 487 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
478 | { | 488 | { |
479 | if (!mailView->currentItem()) return; | 489 | if (!mailView->currentItem()) return; |
480 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 490 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
481 | /* just the RIGHT button - or hold on pda */ | 491 | /* just the RIGHT button - or hold on pda */ |
482 | if (button!=2) {return;} | 492 | if (button!=2) {return;} |
483 | if (!item) return; | 493 | if (!item) return; |
484 | QPopupMenu *m = new QPopupMenu(0); | 494 | QPopupMenu *m = new QPopupMenu(0); |
485 | if (m) | 495 | if (m) |
486 | { | 496 | { |
487 | if (mailtype==MAILLIB::A_NNTP) { | 497 | if (mailtype==MAILLIB::A_NNTP) { |
488 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 498 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
489 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 499 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
490 | m->insertSeparator(); | 500 | m->insertSeparator(); |
491 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 501 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
492 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 502 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
493 | } else { | 503 | } else { |
494 | if (folderView->currentisDraft()) { | 504 | if (folderView->currentisDraft()) { |
495 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 505 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
496 | } | 506 | } |
497 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 507 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
498 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 508 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
499 | m->insertSeparator(); | 509 | m->insertSeparator(); |
500 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 510 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
501 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 511 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
502 | m->insertSeparator(); | 512 | m->insertSeparator(); |
503 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 513 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
504 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 514 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
505 | m->insertSeparator(); | 515 | m->insertSeparator(); |
506 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 516 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
507 | } | 517 | } |
508 | m->setFocus(); | 518 | m->setFocus(); |
509 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 519 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
510 | delete m; | 520 | delete m; |
511 | } | 521 | } |
512 | } | 522 | } |
513 | 523 | ||
514 | void OpieMail::slotShowFolders( bool show ) | 524 | void OpieMail::slotShowFolders( bool show ) |
515 | { | 525 | { |
516 | if ( show && folderView->isHidden() ) | 526 | if ( show && folderView->isHidden() ) |
517 | { | 527 | { |
518 | folderView->show(); | 528 | folderView->show(); |
519 | } | 529 | } |
520 | else if ( !show && !folderView->isHidden() ) | 530 | else if ( !show && !folderView->isHidden() ) |
521 | { | 531 | { |
522 | folderView->hide(); | 532 | folderView->hide(); |
523 | } | 533 | } |
524 | } | 534 | } |
525 | 535 | ||
526 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 536 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
527 | { | 537 | { |
528 | MailListViewItem*item = 0; | 538 | MailListViewItem*item = 0; |
529 | mailView->clear(); | 539 | mailView->clear(); |
530 | 540 | ||
531 | QValueList<RecMailP>::ConstIterator it; | 541 | QValueList<RecMailP>::ConstIterator it; |
532 | for (it = list.begin(); it != list.end();++it) | 542 | for (it = list.begin(); it != list.end();++it) |
533 | { | 543 | { |
534 | item = new MailListViewItem(mailView,item); | 544 | item = new MailListViewItem(mailView,item); |
535 | item->storeData((*it)); | 545 | item->storeData((*it)); |
536 | item->showEntry(); | 546 | item->showEntry(); |
537 | } | 547 | } |
538 | mailView->setSorting ( 4, false ); | 548 | mailView->setSorting ( 4, false ); |
539 | } | 549 | } |
540 | 550 | ||
541 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 551 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
542 | { | 552 | { |
543 | mailView->clearSelection(); | 553 | mailView->clearSelection(); |
544 | /* just LEFT button - or tap with stylus on pda */ | 554 | /* just LEFT button - or tap with stylus on pda */ |
545 | //if (button!=1) return; | 555 | //if (button!=1) return; |
546 | if (!item) return; | 556 | if (!item) return; |
547 | if (folderView->currentisDraft()) { | 557 | if (folderView->currentisDraft()) { |
548 | reEditMail(); | 558 | reEditMail(); |
549 | } else { | 559 | } else { |
550 | displayMail(); | 560 | displayMail(); |
551 | } | 561 | } |
552 | } | 562 | } |
553 | 563 | ||
554 | void OpieMail::slotMoveCopyMail() | 564 | void OpieMail::slotMoveCopyMail() |
555 | { | 565 | { |
556 | if (!mailView->currentItem()) return; | 566 | if (!mailView->currentItem()) return; |
557 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 567 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
558 | AbstractMail*targetMail = 0; | 568 | AbstractMail*targetMail = 0; |
559 | QString targetFolder = ""; | 569 | QString targetFolder = ""; |
560 | Selectstore sels; | 570 | Selectstore sels; |
561 | folderView->setupFolderselect(&sels); | 571 | folderView->setupFolderselect(&sels); |
562 | if (!sels.exec()) return; | 572 | if (!sels.exec()) return; |
563 | targetMail = sels.currentMail(); | 573 | targetMail = sels.currentMail(); |
564 | targetFolder = sels.currentFolder(); | 574 | targetFolder = sels.currentFolder(); |
565 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 575 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
566 | targetFolder.isEmpty()) | 576 | targetFolder.isEmpty()) |
567 | { | 577 | { |
568 | return; | 578 | return; |
569 | } | 579 | } |
570 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 580 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
571 | { | 581 | { |
572 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 582 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
573 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 583 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
574 | return; | 584 | return; |
575 | } | 585 | } |
576 | sels.hide(); | 586 | sels.hide(); |
577 | qApp->processEvents(); | 587 | qApp->processEvents(); |
578 | // qDebug("hiding sels "); | 588 | // qDebug("hiding sels "); |
579 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 589 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
580 | folderView->refreshCurrent(); | 590 | folderView->refreshCurrent(); |
581 | } | 591 | } |
582 | 592 | ||
583 | void OpieMail::slotMoveCopyAllMail() | 593 | void OpieMail::slotMoveCopyAllMail() |
584 | { | 594 | { |
585 | 595 | ||
586 | if (!mailView->currentItem()) return; | 596 | if (!mailView->currentItem()) return; |
587 | QValueList<RecMailP> t; | 597 | QValueList<RecMailP> t; |
588 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 598 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
589 | { | 599 | { |
590 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 600 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
591 | while ( item ) { | 601 | while ( item ) { |
592 | if ( item->isSelected() ) { | 602 | if ( item->isSelected() ) { |
593 | t.append( item->data() ); | 603 | t.append( item->data() ); |
594 | } | 604 | } |
595 | item = (MailListViewItem*)item->nextSibling(); | 605 | item = (MailListViewItem*)item->nextSibling(); |
596 | } | 606 | } |
597 | } | 607 | } |
598 | // else | 608 | // else |
599 | // return; | 609 | // return; |
600 | if ( t.count() == 0 ) | 610 | if ( t.count() == 0 ) |
601 | return; | 611 | return; |
602 | RecMailP mail = t.first(); | 612 | RecMailP mail = t.first(); |
603 | AbstractMail*targetMail = 0; | 613 | AbstractMail*targetMail = 0; |
604 | QString targetFolder = ""; | 614 | QString targetFolder = ""; |
605 | Selectstore sels; | 615 | Selectstore sels; |
606 | folderView->setupFolderselect(&sels); | 616 | folderView->setupFolderselect(&sels); |
607 | if (!sels.exec()) return; | 617 | if (!sels.exec()) return; |
608 | targetMail = sels.currentMail(); | 618 | targetMail = sels.currentMail(); |
609 | targetFolder = sels.currentFolder(); | 619 | targetFolder = sels.currentFolder(); |
610 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 620 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
611 | targetFolder.isEmpty()) | 621 | targetFolder.isEmpty()) |
612 | { | 622 | { |
613 | return; | 623 | return; |
614 | } | 624 | } |
615 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 625 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
616 | { | 626 | { |
617 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 627 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
618 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 628 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
619 | return; | 629 | return; |
620 | } | 630 | } |
621 | sels.hide(); | 631 | sels.hide(); |
622 | qApp->processEvents(); | 632 | qApp->processEvents(); |
623 | //qDebug("hiding sels "); | 633 | //qDebug("hiding sels "); |
624 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 634 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
625 | folderView->refreshCurrent(); | 635 | folderView->refreshCurrent(); |
626 | } | 636 | } |
627 | 637 | ||
628 | void OpieMail::reEditMail() | 638 | void OpieMail::reEditMail() |
629 | { | 639 | { |
630 | if (!mailView->currentItem()) return; | 640 | if (!mailView->currentItem()) return; |
631 | 641 | ||
632 | ComposeMail compose( settings, this, 0, true ); | 642 | ComposeMail compose( settings, this, 0, true ); |
633 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 643 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
634 | compose.slotAdjustColumns(); | 644 | compose.slotAdjustColumns(); |
635 | #ifndef DESKTOP_VERSION | 645 | #ifndef DESKTOP_VERSION |
636 | compose.showMaximized(); | 646 | compose.showMaximized(); |
637 | #else | 647 | #else |
638 | compose.resize(640,480); | 648 | compose.resize(640,480); |
639 | #endif | 649 | #endif |
650 | mCurrentComposer = &compose; | ||
640 | compose.exec(); | 651 | compose.exec(); |
652 | mCurrentComposer = 0; | ||
653 | } | ||
654 | |||
655 | void OpieMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | ||
656 | { | ||
657 | |||
658 | if ( mCurrentComposer ) { | ||
659 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); | ||
660 | } else { | ||
661 | ComposeMail compose( settings, this, 0, true ); | ||
662 | compose.slotAdjustColumns(); | ||
663 | #ifndef DESKTOP_VERSION | ||
664 | compose.showMaximized(); | ||
665 | #endif | ||
666 | mCurrentComposer = &compose; | ||
667 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); | ||
668 | compose.exec(); | ||
669 | mCurrentComposer = 0; | ||
670 | raise(); | ||
671 | } | ||
641 | } | 672 | } |
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h index b8a527f..4f75b3f 100644 --- a/kmicromail/opiemail.h +++ b/kmicromail/opiemail.h | |||
@@ -1,61 +1,66 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef OPIEMAIL_H | 2 | #ifndef OPIEMAIL_H |
3 | #define OPIEMAIL_H | 3 | #define OPIEMAIL_H |
4 | 4 | ||
5 | #include "mainwindow.h" | 5 | #include "mainwindow.h" |
6 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | 7 | ||
8 | #include <opie2/osmartpointer.h> | 8 | #include <opie2/osmartpointer.h> |
9 | #include <libmailwrapper/mailtypes.h> | 9 | #include <libmailwrapper/mailtypes.h> |
10 | #include <viewmail.h> | 10 | #include <viewmail.h> |
11 | #include <qstringlist.h> | ||
12 | |||
13 | class ComposeMail; | ||
11 | 14 | ||
12 | class OpieMail : public MainWindow | 15 | class OpieMail : public MainWindow |
13 | { | 16 | { |
14 | Q_OBJECT | 17 | Q_OBJECT |
15 | 18 | ||
16 | public: | 19 | public: |
17 | OpieMail( QWidget *parent = 0, const char *name = 0 ); | 20 | OpieMail( QWidget *parent = 0, const char *name = 0 ); |
18 | virtual ~OpieMail(); | 21 | virtual ~OpieMail(); |
19 | static QString appName() { return QString::fromLatin1("kopiemail"); } | 22 | static QString appName() { return QString::fromLatin1("kopiemail"); } |
20 | 23 | ||
21 | public slots: | 24 | public slots: |
22 | virtual void slotwriteMail(const QString&name,const QString&email); | 25 | virtual void slotwriteMail(const QString&name,const QString&email); |
23 | virtual void slotwriteMail2(const QString&nameemail); | 26 | virtual void slotwriteMail2(const QString&nameemail); |
24 | virtual void slotComposeMail(); | 27 | virtual void slotComposeMail(); |
25 | virtual void slotExtAppHandler(); | 28 | virtual void slotExtAppHandler(); |
26 | virtual void appMessage(const QCString &msg, const QByteArray &data); | 29 | virtual void appMessage(const QCString &msg, const QByteArray &data); |
27 | virtual void message(const QCString &msg, const QByteArray &data); | 30 | virtual void message(const QCString &msg, const QByteArray &data); |
31 | void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); | ||
28 | protected slots: | 32 | protected slots: |
29 | virtual void deleteAndDisplayNextMail(ViewMail * vm); | 33 | virtual void deleteAndDisplayNextMail(ViewMail * vm); |
30 | virtual void displayNextMail(ViewMail * vm); | 34 | virtual void displayNextMail(ViewMail * vm); |
31 | virtual void slotSendQueued(); | 35 | virtual void slotSendQueued(); |
32 | virtual void slotSearchMails(); | 36 | virtual void slotSearchMails(); |
33 | virtual void slotEditSettings(); | 37 | virtual void slotEditSettings(); |
34 | virtual void slotEditAccounts(); | 38 | virtual void slotEditAccounts(); |
35 | virtual void displayMail(); | 39 | virtual void displayMail(); |
36 | virtual void replyMail(); | 40 | virtual void replyMail(); |
37 | virtual void slotDeleteMail(); | 41 | virtual void slotDeleteMail(); |
38 | virtual void slotGetMail(); | 42 | virtual void slotGetMail(); |
39 | virtual void slotGetAllMail(); | 43 | virtual void slotGetAllMail(); |
40 | virtual void slotDeleteAllMail(); | 44 | virtual void slotDeleteAllMail(); |
41 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | 45 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
42 | virtual void slotShowFolders( bool show ); | 46 | virtual void slotShowFolders( bool show ); |
43 | virtual void refreshMailView(const QValueList<RecMailP>&); | 47 | virtual void refreshMailView(const QValueList<RecMailP>&); |
44 | virtual void mailLeftClicked( QListViewItem * ); | 48 | virtual void mailLeftClicked( QListViewItem * ); |
45 | virtual void slotMoveCopyMail(); | 49 | virtual void slotMoveCopyMail(); |
46 | virtual void slotMoveCopyAllMail(); | 50 | virtual void slotMoveCopyAllMail(); |
47 | virtual void reEditMail(); | 51 | virtual void reEditMail(); |
48 | void clearSelection(); | 52 | void clearSelection(); |
49 | void slotDownloadMail(); | 53 | void slotDownloadMail(); |
50 | private: | 54 | private: |
55 | ComposeMail* mCurrentComposer; | ||
51 | void closeViewMail(ViewMail * vm); | 56 | void closeViewMail(ViewMail * vm); |
52 | QString mPendingEmail; | 57 | QString mPendingEmail; |
53 | QString mPendingName; | 58 | QString mPendingName; |
54 | QByteArray mPendingData; | 59 | QByteArray mPendingData; |
55 | QCString mPendingMessage; | 60 | QCString mPendingMessage; |
56 | Settings *settings; | 61 | Settings *settings; |
57 | QTextBrowser * tb; | 62 | QTextBrowser * tb; |
58 | 63 | ||
59 | }; | 64 | }; |
60 | 65 | ||
61 | #endif | 66 | #endif |