-rw-r--r-- | kmicromail/composemail.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 9efa932..9b799b3 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -2,210 +2,210 @@ | |||
2 | 2 | ||
3 | #include "composemail.h" | 3 | #include "composemail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/smtpwrapper.h> | 5 | #include <libmailwrapper/smtpwrapper.h> |
6 | #include <libmailwrapper/storemail.h> | 6 | #include <libmailwrapper/storemail.h> |
7 | #include <libmailwrapper/abstractmail.h> | 7 | #include <libmailwrapper/abstractmail.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/ofiledialog.h> | 11 | //#include <opie2/ofiledialog.h> |
12 | //#include <opie2/odebug.h> | 12 | //#include <opie2/odebug.h> |
13 | #include <kfiledialog.h> | 13 | #include <kfiledialog.h> |
14 | //#include <qpe/resource.h> | 14 | //#include <qpe/resource.h> |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/global.h> | 16 | #include <qpe/global.h> |
17 | //#include <qpe/contact.h> | 17 | //#include <qpe/contact.h> |
18 | 18 | ||
19 | 19 | ||
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qcheckbox.h> | 21 | #include <qcheckbox.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qmultilineedit.h> | 25 | #include <qmultilineedit.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qtabwidget.h> | 27 | #include <qtabwidget.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <kabc/addresseedialog.h> | 29 | #include <kabc/addresseedialog.h> |
30 | #include <kabc/stdaddressbook.h> | 30 | #include <kabc/stdaddressbook.h> |
31 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
32 | #ifdef DESKTOP_VERSION | 32 | #ifdef DESKTOP_VERSION |
33 | #include <kabc/addresseedialog.h> | 33 | #include <kabc/addresseedialog.h> |
34 | #else //DESKTOP_VERSION | 34 | #else //DESKTOP_VERSION |
35 | #include <libkdepim/externalapphandler.h> | 35 | #include <libkdepim/externalapphandler.h> |
36 | #endif //DESKTOP_VERSION | 36 | #endif //DESKTOP_VERSION |
37 | 37 | ||
38 | 38 | ||
39 | //using namespace Opie::Core; | 39 | //using namespace Opie::Core; |
40 | //using namespace Opie::Ui; | 40 | //using namespace Opie::Ui; |
41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) | 41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) |
42 | : ComposeMailUI( parent, name, modal ) | 42 | : ComposeMailUI( parent, name, modal ) |
43 | { | 43 | { |
44 | 44 | ||
45 | mPickLineEdit = 0; | 45 | mPickLineEdit = 0; |
46 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 46 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
47 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 47 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
48 | settings = s; | 48 | settings = s; |
49 | m_replyid = ""; | 49 | m_replyid = ""; |
50 | KConfig config( locateLocal("config", "kabcrc") ); | 50 | KConfig config( locateLocal("config", "kabcrc") ); |
51 | config.setGroup( "General" ); | 51 | config.setGroup( "General" ); |
52 | QString whoami_uid = config.readEntry( "WhoAmI" ); | 52 | QString whoami_uid = config.readEntry( "WhoAmI" ); |
53 | 53 | ||
54 | if ( whoami_uid.isEmpty() ) { | 54 | if ( whoami_uid.isEmpty() ) { |
55 | QMessageBox::information( 0, tr( "Hint" ), | 55 | QMessageBox::information( 0, tr( "Hint" ), |
56 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 56 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
57 | tr( "Ok" ) ); | 57 | tr( "Ok" ) ); |
58 | 58 | ||
59 | } else | 59 | } else |
60 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | 60 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); |
61 | 61 | ||
62 | 62 | ||
63 | #ifdef DESKTOP_VERSION | 63 | #ifdef DESKTOP_VERSION |
64 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 64 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
65 | QStringList mails = con.emails(); | 65 | QStringList mails = con.emails(); |
66 | QString defmail = con.preferredEmail(); | 66 | QString defmail = con.preferredEmail(); |
67 | if ( mails.count() == 0) | 67 | if ( mails.count() == 0) |
68 | QMessageBox::information( 0, tr( "Hint" ), | 68 | QMessageBox::information( 0, tr( "Hint" ), |
69 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 69 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
70 | tr( "Ok" ) ); | 70 | tr( "Ok" ) ); |
71 | if (defmail.length()!=0) { | 71 | if (defmail.length()!=0) { |
72 | fromBox->insertItem(defmail); | 72 | fromBox->insertItem(defmail); |
73 | } | 73 | } |
74 | QStringList::ConstIterator sit = mails.begin(); | 74 | QStringList::ConstIterator sit = mails.begin(); |
75 | for (;sit!=mails.end();++sit) { | 75 | for (;sit!=mails.end();++sit) { |
76 | if ( (*sit)==defmail) | 76 | if ( (*sit)==defmail) |
77 | continue; | 77 | continue; |
78 | fromBox->insertItem((*sit)); | 78 | fromBox->insertItem((*sit)); |
79 | } | 79 | } |
80 | senderNameEdit->setText(con.formattedName()); | 80 | senderNameEdit->setText(con.formattedName()); |
81 | #endif | 81 | #endif |
82 | Config cfg( "mail" ); | 82 | Config cfg( "mail" ); |
83 | cfg.setGroup( "Compose" ); | 83 | cfg.setGroup( "Compose" ); |
84 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 84 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
85 | 85 | ||
86 | attList->addColumn( tr( "Name" ) ); | 86 | attList->addColumn( tr( "Name" ) ); |
87 | attList->addColumn( tr( "Size" ) ); | 87 | attList->addColumn( tr( "Size" ) ); |
88 | QList<Account> accounts = settings->getAccounts(); | 88 | QList<Account> accounts = settings->getAccounts(); |
89 | 89 | ||
90 | Account *it; | 90 | Account *it; |
91 | for ( it = accounts.first(); it; it = accounts.next() ) { | 91 | for ( it = accounts.first(); it; it = accounts.next() ) { |
92 | if ( it->getType()==MAILLIB::A_SMTP ) { | 92 | if ( it->getType()==MAILLIB::A_SMTP ) { |
93 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 93 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
94 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 94 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
95 | smtpAccounts.append( smtp ); | 95 | smtpAccounts.append( smtp ); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | if ( smtpAccounts.count() > 0 ) { | ||
99 | fillValues( smtpAccountBox->currentItem() ); | ||
100 | } else { | ||
101 | QMessageBox::information( 0, tr( "Problem" ), | ||
102 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), | ||
103 | tr( "Ok" ) ); | ||
104 | return; | ||
105 | } | ||
106 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | ||
107 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 98 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
108 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 99 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
109 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 100 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
110 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 101 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
111 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 102 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
112 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 103 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
113 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 104 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
114 | mMail = 0; | 105 | mMail = 0; |
115 | warnAttach = true; | 106 | warnAttach = true; |
107 | if ( smtpAccounts.count() > 0 ) { | ||
108 | fillValues( smtpAccountBox->currentItem() ); | ||
109 | } else { | ||
110 | QMessageBox::information( 0, tr( "Problem" ), | ||
111 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), | ||
112 | tr( "Ok" ) ); | ||
113 | return; | ||
114 | } | ||
115 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | ||
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | 120 | ||
121 | void ComposeMail::saveAsDraft() | 121 | void ComposeMail::saveAsDraft() |
122 | { | 122 | { |
123 | 123 | ||
124 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 124 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
125 | mail->setMail(fromBox->currentText()); | 125 | mail->setMail(fromBox->currentText()); |
126 | mail->setTo( toLine->text() ); | 126 | mail->setTo( toLine->text() ); |
127 | mail->setName(senderNameEdit->text()); | 127 | mail->setName(senderNameEdit->text()); |
128 | mail->setCC( ccLine->text() ); | 128 | mail->setCC( ccLine->text() ); |
129 | mail->setBCC( bccLine->text() ); | 129 | mail->setBCC( bccLine->text() ); |
130 | mail->setReply( replyLine->text() ); | 130 | mail->setReply( replyLine->text() ); |
131 | mail->setSubject( subjectLine->text() ); | 131 | mail->setSubject( subjectLine->text() ); |
132 | if (!m_replyid.isEmpty()) { | 132 | if (!m_replyid.isEmpty()) { |
133 | QStringList ids; | 133 | QStringList ids; |
134 | ids.append(m_replyid); | 134 | ids.append(m_replyid); |
135 | mail->setInreply(ids); | 135 | mail->setInreply(ids); |
136 | } | 136 | } |
137 | QString txt = message->text(); | 137 | QString txt = message->text(); |
138 | if ( !sigMultiLine->text().isEmpty() ) { | 138 | if ( !sigMultiLine->text().isEmpty() ) { |
139 | txt.append( "\n--\n" ); | 139 | txt.append( "\n--\n" ); |
140 | txt.append( sigMultiLine->text() ); | 140 | txt.append( sigMultiLine->text() ); |
141 | } | 141 | } |
142 | mail->setMessage( txt ); | 142 | mail->setMessage( txt ); |
143 | 143 | ||
144 | /* only use the default drafts folder name! */ | 144 | /* only use the default drafts folder name! */ |
145 | Storemail wrapper(AbstractMail::draftFolder()); | 145 | Storemail wrapper(AbstractMail::draftFolder()); |
146 | wrapper.storeMail(mail); | 146 | wrapper.storeMail(mail); |
147 | 147 | ||
148 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 148 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
149 | /* attachments we will ignore! */ | 149 | /* attachments we will ignore! */ |
150 | if ( it != 0 ) { | 150 | if ( it != 0 ) { |
151 | if ( warnAttach ) | 151 | if ( warnAttach ) |
152 | QMessageBox::warning(0,tr("Store message"), | 152 | QMessageBox::warning(0,tr("Store message"), |
153 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 153 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
154 | warnAttach = false; | 154 | warnAttach = false; |
155 | } | 155 | } |
156 | setStatus( tr("Mail saved as draft!") ); | 156 | setStatus( tr("Mail saved as draft!") ); |
157 | } | 157 | } |
158 | void ComposeMail::clearStatus() | 158 | void ComposeMail::clearStatus() |
159 | { | 159 | { |
160 | topLevelWidget()->setCaption( tr("Compose mail") ); | 160 | topLevelWidget()->setCaption( tr("Compose mail") ); |
161 | } | 161 | } |
162 | void ComposeMail::setStatus( QString status ) | 162 | void ComposeMail::setStatus( QString status ) |
163 | { | 163 | { |
164 | topLevelWidget()->setCaption( status ); | 164 | topLevelWidget()->setCaption( status ); |
165 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; | 165 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; |
166 | } | 166 | } |
167 | void ComposeMail::pickAddress( ) | 167 | void ComposeMail::pickAddress( ) |
168 | { | 168 | { |
169 | 169 | ||
170 | QLineEdit *line = mPickLineEdit; | 170 | QLineEdit *line = mPickLineEdit; |
171 | if ( line == 0 ) | 171 | if ( line == 0 ) |
172 | return; | 172 | return; |
173 | #ifdef DESKTOP_VERSION | 173 | #ifdef DESKTOP_VERSION |
174 | //qDebug(" ComposeMail::pickAddress "); | 174 | //qDebug(" ComposeMail::pickAddress "); |
175 | QString names ;//= AddressPicker::getNames(); | 175 | QString names ;//= AddressPicker::getNames(); |
176 | 176 | ||
177 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 177 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
178 | uint i=0; | 178 | uint i=0; |
179 | for (i=0; i < list.count(); i++) { | 179 | for (i=0; i < list.count(); i++) { |
180 | if ( !list[i].preferredEmail().isEmpty()) { | 180 | if ( !list[i].preferredEmail().isEmpty()) { |
181 | if ( ! names.isEmpty() ) | 181 | if ( ! names.isEmpty() ) |
182 | names+= ","; | 182 | names+= ","; |
183 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 183 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; |
184 | 184 | ||
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | if ( line->text().isEmpty() ) { | 189 | if ( line->text().isEmpty() ) { |
190 | line->setText( names ); | 190 | line->setText( names ); |
191 | } else if ( !names.isEmpty() ) { | 191 | } else if ( !names.isEmpty() ) { |
192 | line->setText( line->text() + ", " + names ); | 192 | line->setText( line->text() + ", " + names ); |
193 | } | 193 | } |
194 | #else | 194 | #else |
195 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | 195 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); |
196 | // the result should now arrive through method insertAttendees | 196 | // the result should now arrive through method insertAttendees |
197 | #endif | 197 | #endif |
198 | } | 198 | } |
199 | //the map includes name/email pairs, that comes from Ka/Pi | 199 | //the map includes name/email pairs, that comes from Ka/Pi |
200 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 200 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
201 | { | 201 | { |
202 | //qDebug("ComposeMail::insertAttendees "); | 202 | //qDebug("ComposeMail::insertAttendees "); |
203 | raise(); | 203 | raise(); |
204 | 204 | ||
205 | if ( mPickLineEdit == 0 ) { //whoami received | 205 | if ( mPickLineEdit == 0 ) { //whoami received |
206 | QString defmail = uidList[0]; | 206 | QString defmail = uidList[0]; |
207 | if ( emailList.count() == 0 ) | 207 | if ( emailList.count() == 0 ) |
208 | QMessageBox::information( 0, tr( "Hint" ), | 208 | QMessageBox::information( 0, tr( "Hint" ), |
209 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 209 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
210 | tr( "Ok" ) ); | 210 | tr( "Ok" ) ); |
211 | if (defmail.length()!=0) { | 211 | if (defmail.length()!=0) { |