author | zecke <zecke> | 2004-10-23 13:36:29 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-23 13:36:29 (UTC) |
commit | b5d111eb79896d02aa13d41a04ce6aa4dbc4aa49 (patch) (unidiff) | |
tree | 6f350aa52697c9ed9ecf7bed6796c4138cb70f68 | |
parent | aac8188fde70fc5cfa9f44c6a80a907e44f0f1eb (diff) | |
download | opie-b5d111eb79896d02aa13d41a04ce6aa4dbc4aa49.zip opie-b5d111eb79896d02aa13d41a04ce6aa4dbc4aa49.tar.gz opie-b5d111eb79896d02aa13d41a04ce6aa4dbc4aa49.tar.bz2 |
Integrate opiemail with Konqueror. When now clicking on a mailto link
in Konqueror OpieMail can get asked to send a mail to the persopn
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 2f87e44..b153292 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -1,258 +1,270 @@ | |||
1 | 1 | ||
2 | #include "settingsdialog.h" | 2 | #include "settingsdialog.h" |
3 | #include "opiemail.h" | 3 | #include "opiemail.h" |
4 | #include "editaccounts.h" | 4 | #include "editaccounts.h" |
5 | #include "composemail.h" | 5 | #include "composemail.h" |
6 | #include "mailistviewitem.h" | 6 | #include "mailistviewitem.h" |
7 | #include "viewmail.h" | 7 | #include "viewmail.h" |
8 | #include "selectstore.h" | 8 | #include "selectstore.h" |
9 | #include "selectsmtp.h" | 9 | #include "selectsmtp.h" |
10 | 10 | ||
11 | #include <libmailwrapper/smtpwrapper.h> | 11 | #include <libmailwrapper/smtpwrapper.h> |
12 | #include <libmailwrapper/mailtypes.h> | 12 | #include <libmailwrapper/mailtypes.h> |
13 | #include <libmailwrapper/abstractmail.h> | 13 | #include <libmailwrapper/abstractmail.h> |
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
18 | 18 | ||
19 | /* QT */ | 19 | /* QT */ |
20 | 20 | ||
21 | /* UNIX */ | 21 | /* UNIX */ |
22 | #include <signal.h> | 22 | #include <signal.h> |
23 | 23 | ||
24 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
25 | 25 | ||
26 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | 26 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) |
27 | : MainWindow( parent, name, WStyle_ContextHelp ) | 27 | : MainWindow( parent, name, WStyle_ContextHelp ) |
28 | { | 28 | { |
29 | setup_signalblocking(); | 29 | setup_signalblocking(); |
30 | settings = new Settings(); | 30 | settings = new Settings(); |
31 | 31 | ||
32 | folderView->populate( settings->getAccounts() ); | 32 | folderView->populate( settings->getAccounts() ); |
33 | } | 33 | } |
34 | 34 | ||
35 | OpieMail::~OpieMail() | 35 | OpieMail::~OpieMail() |
36 | { | 36 | { |
37 | if (settings) delete settings; | 37 | if (settings) delete settings; |
38 | } | 38 | } |
39 | 39 | ||
40 | void OpieMail::setup_signalblocking() | 40 | void OpieMail::setup_signalblocking() |
41 | { | 41 | { |
42 | /* for networking we must block SIGPIPE and Co. */ | 42 | /* for networking we must block SIGPIPE and Co. */ |
43 | struct sigaction blocking_action,temp_action; | 43 | struct sigaction blocking_action,temp_action; |
44 | blocking_action.sa_handler = SIG_IGN; | 44 | blocking_action.sa_handler = SIG_IGN; |
45 | sigemptyset(&(blocking_action.sa_mask)); | 45 | sigemptyset(&(blocking_action.sa_mask)); |
46 | blocking_action.sa_flags = 0; | 46 | blocking_action.sa_flags = 0; |
47 | sigaction(SIGPIPE,&blocking_action,&temp_action); | 47 | sigaction(SIGPIPE,&blocking_action,&temp_action); |
48 | } | 48 | } |
49 | 49 | ||
50 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 50 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
51 | { | 51 | { |
52 | // copied from old mail2 | 52 | // copied from old mail2 |
53 | if (msg == "writeMail(QString,QString)") | 53 | if (msg == "writeMail(QString,QString)") |
54 | { | 54 | { |
55 | QDataStream stream(data,IO_ReadOnly); | 55 | QDataStream stream(data,IO_ReadOnly); |
56 | QString name, email; | 56 | QString name, email; |
57 | stream >> name >> email; | 57 | stream >> name >> email; |
58 | // removing the whitespaces at beginning and end is needed! | 58 | // removing the whitespaces at beginning and end is needed! |
59 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); | 59 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); |
60 | } | 60 | } |
61 | else if (msg == "newMail()") | 61 | else if (msg == "newMail()") |
62 | { | 62 | { |
63 | slotComposeMail(); | 63 | slotComposeMail(); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | /** | ||
68 | * Konqueror calls us with the mailto:name@address | ||
69 | */ | ||
70 | void OpieMail::setDocument(const QString& mail) | ||
71 | { | ||
72 | /* | ||
73 | * It looks like a mailto address, lets try it | ||
74 | */ | ||
75 | if( mail.startsWith(QString::fromLatin1("mailto:")) ) | ||
76 | slotwriteMail(QString::null, mail.mid(7)); | ||
77 | } | ||
78 | |||
67 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 79 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
68 | { | 80 | { |
69 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 81 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); |
70 | if (!email.isEmpty()) | 82 | if (!email.isEmpty()) |
71 | { | 83 | { |
72 | if (!name.isEmpty()) | 84 | if (!name.isEmpty()) |
73 | { | 85 | { |
74 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 86 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
75 | } | 87 | } |
76 | else | 88 | else |
77 | { | 89 | { |
78 | compose.setTo(email); | 90 | compose.setTo(email); |
79 | } | 91 | } |
80 | } | 92 | } |
81 | compose.slotAdjustColumns(); | 93 | compose.slotAdjustColumns(); |
82 | QPEApplication::execDialog( &compose ); | 94 | QPEApplication::execDialog( &compose ); |
83 | } | 95 | } |
84 | 96 | ||
85 | void OpieMail::slotComposeMail() | 97 | void OpieMail::slotComposeMail() |
86 | { | 98 | { |
87 | odebug << "Compose Mail" << oendl; | 99 | odebug << "Compose Mail" << oendl; |
88 | slotwriteMail(0l,0l); | 100 | slotwriteMail(0l,0l); |
89 | } | 101 | } |
90 | 102 | ||
91 | void OpieMail::slotSendQueued() | 103 | void OpieMail::slotSendQueued() |
92 | { | 104 | { |
93 | odebug << "Send Queued" << oendl; | 105 | odebug << "Send Queued" << oendl; |
94 | SMTPaccount *smtp = 0; | 106 | SMTPaccount *smtp = 0; |
95 | 107 | ||
96 | QList<Account> list = settings->getAccounts(); | 108 | QList<Account> list = settings->getAccounts(); |
97 | QList<SMTPaccount> smtpList; | 109 | QList<SMTPaccount> smtpList; |
98 | smtpList.setAutoDelete(false); | 110 | smtpList.setAutoDelete(false); |
99 | Account *it; | 111 | Account *it; |
100 | for ( it = list.first(); it; it = list.next() ) | 112 | for ( it = list.first(); it; it = list.next() ) |
101 | { | 113 | { |
102 | if ( it->getType() == MAILLIB::A_SMTP ) | 114 | if ( it->getType() == MAILLIB::A_SMTP ) |
103 | { | 115 | { |
104 | smtp = static_cast<SMTPaccount *>(it); | 116 | smtp = static_cast<SMTPaccount *>(it); |
105 | smtpList.append(smtp); | 117 | smtpList.append(smtp); |
106 | } | 118 | } |
107 | } | 119 | } |
108 | if (smtpList.count()==0) | 120 | if (smtpList.count()==0) |
109 | { | 121 | { |
110 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); | 122 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); |
111 | return; | 123 | return; |
112 | } | 124 | } |
113 | if (smtpList.count()==1) | 125 | if (smtpList.count()==1) |
114 | { | 126 | { |
115 | smtp = smtpList.at(0); | 127 | smtp = smtpList.at(0); |
116 | } | 128 | } |
117 | else | 129 | else |
118 | { | 130 | { |
119 | smtp = 0; | 131 | smtp = 0; |
120 | selectsmtp selsmtp; | 132 | selectsmtp selsmtp; |
121 | selsmtp.setSelectionlist(&smtpList); | 133 | selsmtp.setSelectionlist(&smtpList); |
122 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) | 134 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) |
123 | { | 135 | { |
124 | smtp = selsmtp.selected_smtp(); | 136 | smtp = selsmtp.selected_smtp(); |
125 | } | 137 | } |
126 | } | 138 | } |
127 | if (smtp) | 139 | if (smtp) |
128 | { | 140 | { |
129 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 141 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
130 | if ( wrap->flushOutbox() ) | 142 | if ( wrap->flushOutbox() ) |
131 | { | 143 | { |
132 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 144 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
133 | } | 145 | } |
134 | delete wrap; | 146 | delete wrap; |
135 | } | 147 | } |
136 | } | 148 | } |
137 | 149 | ||
138 | void OpieMail::slotSearchMails() | 150 | void OpieMail::slotSearchMails() |
139 | { | 151 | { |
140 | odebug << "Search Mails" << oendl; | 152 | odebug << "Search Mails" << oendl; |
141 | } | 153 | } |
142 | 154 | ||
143 | void OpieMail::slotEditSettings() | 155 | void OpieMail::slotEditSettings() |
144 | { | 156 | { |
145 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 157 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
146 | QPEApplication::execDialog( &settingsDialog ); | 158 | QPEApplication::execDialog( &settingsDialog ); |
147 | } | 159 | } |
148 | 160 | ||
149 | void OpieMail::slotEditAccounts() | 161 | void OpieMail::slotEditAccounts() |
150 | { | 162 | { |
151 | odebug << "Edit Accounts" << oendl; | 163 | odebug << "Edit Accounts" << oendl; |
152 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 164 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
153 | eaDialog.slotAdjustColumns(); | 165 | eaDialog.slotAdjustColumns(); |
154 | QPEApplication::execDialog( &eaDialog ); | 166 | QPEApplication::execDialog( &eaDialog ); |
155 | if ( settings ) delete settings; | 167 | if ( settings ) delete settings; |
156 | settings = new Settings(); | 168 | settings = new Settings(); |
157 | 169 | ||
158 | folderView->populate( settings->getAccounts() ); | 170 | folderView->populate( settings->getAccounts() ); |
159 | } | 171 | } |
160 | 172 | ||
161 | void OpieMail::displayMail() | 173 | void OpieMail::displayMail() |
162 | { | 174 | { |
163 | QListViewItem*item = mailView->currentItem(); | 175 | QListViewItem*item = mailView->currentItem(); |
164 | if (!item) return; | 176 | if (!item) return; |
165 | RecMailP mail = ((MailListViewItem*)item)->data(); | 177 | RecMailP mail = ((MailListViewItem*)item)->data(); |
166 | RecBodyP body = folderView->fetchBody(mail); | 178 | RecBodyP body = folderView->fetchBody(mail); |
167 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 179 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
168 | readMail.setBody( body ); | 180 | readMail.setBody( body ); |
169 | readMail.setMail( mail ); | 181 | readMail.setMail( mail ); |
170 | readMail.showMaximized(); | 182 | readMail.showMaximized(); |
171 | readMail.exec(); | 183 | readMail.exec(); |
172 | 184 | ||
173 | if ( readMail.deleted ) | 185 | if ( readMail.deleted ) |
174 | { | 186 | { |
175 | folderView->refreshCurrent(); | 187 | folderView->refreshCurrent(); |
176 | } | 188 | } |
177 | else | 189 | else |
178 | { | 190 | { |
179 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); | 191 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); |
180 | } | 192 | } |
181 | } | 193 | } |
182 | 194 | ||
183 | void OpieMail::slotDeleteMail() | 195 | void OpieMail::slotDeleteMail() |
184 | { | 196 | { |
185 | if (!mailView->currentItem()) return; | 197 | if (!mailView->currentItem()) return; |
186 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 198 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
187 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 199 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
188 | { | 200 | { |
189 | mail->Wrapper()->deleteMail( mail ); | 201 | mail->Wrapper()->deleteMail( mail ); |
190 | folderView->refreshCurrent(); | 202 | folderView->refreshCurrent(); |
191 | } | 203 | } |
192 | } | 204 | } |
193 | 205 | ||
194 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 206 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
195 | { | 207 | { |
196 | if (!mailView->currentItem()) return; | 208 | if (!mailView->currentItem()) return; |
197 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 209 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
198 | /* just the RIGHT button - or hold on pda */ | 210 | /* just the RIGHT button - or hold on pda */ |
199 | if (button!=2) {return;} | 211 | if (button!=2) {return;} |
200 | odebug << "Event right/hold" << oendl; | 212 | odebug << "Event right/hold" << oendl; |
201 | if (!item) return; | 213 | if (!item) return; |
202 | QPopupMenu *m = new QPopupMenu(0); | 214 | QPopupMenu *m = new QPopupMenu(0); |
203 | if (m) | 215 | if (m) |
204 | { | 216 | { |
205 | if (mailtype==MAILLIB::A_NNTP) { | 217 | if (mailtype==MAILLIB::A_NNTP) { |
206 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); | 218 | m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); |
207 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 219 | // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
208 | } else { | 220 | } else { |
209 | if (folderView->currentisDraft()) { | 221 | if (folderView->currentisDraft()) { |
210 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); | 222 | m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); |
211 | } | 223 | } |
212 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 224 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
213 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 225 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
214 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | 226 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); |
215 | } | 227 | } |
216 | m->setFocus(); | 228 | m->setFocus(); |
217 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 229 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
218 | delete m; | 230 | delete m; |
219 | } | 231 | } |
220 | } | 232 | } |
221 | 233 | ||
222 | void OpieMail::slotShowFolders( bool show ) | 234 | void OpieMail::slotShowFolders( bool show ) |
223 | { | 235 | { |
224 | odebug << "Show Folders" << oendl; | 236 | odebug << "Show Folders" << oendl; |
225 | if ( show && folderView->isHidden() ) | 237 | if ( show && folderView->isHidden() ) |
226 | { | 238 | { |
227 | odebug << "-> showing" << oendl; | 239 | odebug << "-> showing" << oendl; |
228 | folderView->show(); | 240 | folderView->show(); |
229 | } | 241 | } |
230 | else if ( !show && !folderView->isHidden() ) | 242 | else if ( !show && !folderView->isHidden() ) |
231 | { | 243 | { |
232 | odebug << "-> hiding" << oendl; | 244 | odebug << "-> hiding" << oendl; |
233 | folderView->hide(); | 245 | folderView->hide(); |
234 | } | 246 | } |
235 | } | 247 | } |
236 | 248 | ||
237 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 249 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
238 | { | 250 | { |
239 | MailListViewItem*item = 0; | 251 | MailListViewItem*item = 0; |
240 | mailView->clear(); | 252 | mailView->clear(); |
241 | 253 | ||
242 | QValueList<RecMailP>::ConstIterator it; | 254 | QValueList<RecMailP>::ConstIterator it; |
243 | for (it = list.begin(); it != list.end();++it) | 255 | for (it = list.begin(); it != list.end();++it) |
244 | { | 256 | { |
245 | item = new MailListViewItem(mailView,item); | 257 | item = new MailListViewItem(mailView,item); |
246 | item->storeData((*it)); | 258 | item->storeData((*it)); |
247 | item->showEntry(); | 259 | item->showEntry(); |
248 | } | 260 | } |
249 | } | 261 | } |
250 | 262 | ||
251 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | 263 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) |
252 | { | 264 | { |
253 | /* just LEFT button - or tap with stylus on pda */ | 265 | /* just LEFT button - or tap with stylus on pda */ |
254 | if (button!=1) return; | 266 | if (button!=1) return; |
255 | if (!item) return; | 267 | if (!item) return; |
256 | if (folderView->currentisDraft()) { | 268 | if (folderView->currentisDraft()) { |
257 | reEditMail(); | 269 | reEditMail(); |
258 | } else { | 270 | } else { |