Diffstat (limited to 'noncore/net/mail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 2bbc8f1..9eba23e 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -62,104 +62,97 @@ public: | |||
62 | 62 | ||
63 | ValueExplode::~ValueExplode() | 63 | ValueExplode::~ValueExplode() |
64 | { | 64 | { |
65 | } | 65 | } |
66 | 66 | ||
67 | ValueExplode::ValueExplode(const QString&aCommand,const char aDelemiter,const char a2Delemiter) | 67 | ValueExplode::ValueExplode(const QString&aCommand,const char aDelemiter,const char a2Delemiter) |
68 | :m_LastParsed(),m_Command(aCommand) | 68 | :m_LastParsed(),m_Command(aCommand) |
69 | { | 69 | { |
70 | mDelemiter = aDelemiter; | 70 | mDelemiter = aDelemiter; |
71 | m2Delemiter = a2Delemiter; | 71 | m2Delemiter = a2Delemiter; |
72 | splitit(); | 72 | splitit(); |
73 | } | 73 | } |
74 | 74 | ||
75 | void ValueExplode::splitit() | 75 | void ValueExplode::splitit() |
76 | { | 76 | { |
77 | QString iLine; | 77 | QString iLine; |
78 | m_LastParsed.clear(); | 78 | m_LastParsed.clear(); |
79 | if (mDelemiter.isEmpty()||m2Delemiter.isEmpty()) { | 79 | if (mDelemiter.isEmpty()||m2Delemiter.isEmpty()) { |
80 | m_LastParsed.append(tkeyvalues(m_Command,"")); | 80 | m_LastParsed.append(tkeyvalues(m_Command,"")); |
81 | return; | 81 | return; |
82 | } | 82 | } |
83 | int pos,pos2,startpos; | 83 | int pos,pos2,startpos; |
84 | startpos = 0; | 84 | startpos = 0; |
85 | iLine = m_Command; | 85 | iLine = m_Command; |
86 | while ( (pos = iLine.find(mDelemiter,startpos))!=-1) { | 86 | while ( (pos = iLine.find(mDelemiter,startpos))!=-1) { |
87 | pos2 = iLine.find(m2Delemiter,startpos); | 87 | pos2 = iLine.find(m2Delemiter,startpos); |
88 | if (pos2==-1||pos2>pos) { | 88 | if (pos2==-1||pos2>pos) { |
89 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos-startpos),"")); | 89 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos-startpos),"")); |
90 | } else { | 90 | } else { |
91 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1,pos-pos2-1))); | 91 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1,pos-pos2-1))); |
92 | } | 92 | } |
93 | startpos = pos+1; | 93 | startpos = pos+1; |
94 | } | 94 | } |
95 | if (startpos<iLine.length()) { | 95 | if (startpos<iLine.length()) { |
96 | pos2 = iLine.find(m2Delemiter,startpos); | 96 | pos2 = iLine.find(m2Delemiter,startpos); |
97 | if (pos2==-1) { | 97 | if (pos2==-1) { |
98 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos),"")); | 98 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos),"")); |
99 | } else { | 99 | } else { |
100 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1))); | 100 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1))); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) | 105 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) |
106 | : MainWindow( parent, name, WStyle_ContextHelp ) | 106 | : MainWindow( parent, name, WStyle_ContextHelp ) |
107 | { | 107 | { |
108 | setup_signalblocking(); | 108 | setup_signalblocking(); |
109 | settings = new Settings(); | 109 | settings = new Settings(); |
110 | |||
111 | folderView->populate( settings->getAccounts() ); | 110 | folderView->populate( settings->getAccounts() ); |
112 | #if 0 | ||
113 | tvaluelist s = ValueExplode("a=1&b=holladiewaldfee&c=3&d=&e=3450"); | ||
114 | for (int i = 0; i < s.count();++i) { | ||
115 | odebug<<"Key: " << s[i].key << " Value: " << s[i].data << oendl; | ||
116 | } | ||
117 | #endif | ||
118 | } | 111 | } |
119 | 112 | ||
120 | OpieMail::~OpieMail() | 113 | OpieMail::~OpieMail() |
121 | { | 114 | { |
122 | if (settings) delete settings; | 115 | if (settings) delete settings; |
123 | } | 116 | } |
124 | 117 | ||
125 | void OpieMail::setup_signalblocking() | 118 | void OpieMail::setup_signalblocking() |
126 | { | 119 | { |
127 | /* for networking we must block SIGPIPE and Co. */ | 120 | /* for networking we must block SIGPIPE and Co. */ |
128 | struct sigaction blocking_action,temp_action; | 121 | struct sigaction blocking_action,temp_action; |
129 | blocking_action.sa_handler = SIG_IGN; | 122 | blocking_action.sa_handler = SIG_IGN; |
130 | sigemptyset(&(blocking_action.sa_mask)); | 123 | sigemptyset(&(blocking_action.sa_mask)); |
131 | blocking_action.sa_flags = 0; | 124 | blocking_action.sa_flags = 0; |
132 | sigaction(SIGPIPE,&blocking_action,&temp_action); | 125 | sigaction(SIGPIPE,&blocking_action,&temp_action); |
133 | } | 126 | } |
134 | 127 | ||
135 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 128 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
136 | { | 129 | { |
137 | // copied from old mail2 | 130 | // copied from old mail2 |
138 | if (msg == "writeMail(QString,QString)") | 131 | if (msg == "writeMail(QString,QString)") |
139 | { | 132 | { |
140 | QDataStream stream(data,IO_ReadOnly); | 133 | QDataStream stream(data,IO_ReadOnly); |
141 | QString name, email; | 134 | QString name, email; |
142 | stream >> name >> email; | 135 | stream >> name >> email; |
143 | // removing the whitespaces at beginning and end is needed! | 136 | // removing the whitespaces at beginning and end is needed! |
144 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); | 137 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); |
145 | } | 138 | } |
146 | else if (msg == "newMail()") | 139 | else if (msg == "newMail()") |
147 | { | 140 | { |
148 | slotComposeMail(); | 141 | slotComposeMail(); |
149 | } | 142 | } |
150 | } | 143 | } |
151 | 144 | ||
152 | /** | 145 | /** |
153 | * Konqueror calls us with the mailto:name@address | 146 | * Konqueror calls us with the mailto:name@address |
154 | */ | 147 | */ |
155 | void OpieMail::setDocument(const QString& mail) | 148 | void OpieMail::setDocument(const QString& mail) |
156 | { | 149 | { |
157 | /* | 150 | /* |
158 | * It looks like a mailto address, lets try it | 151 | * It looks like a mailto address, lets try it |
159 | */ | 152 | */ |
160 | if( mail.startsWith(QString::fromLatin1("mailto:")) ) | 153 | if( mail.startsWith(QString::fromLatin1("mailto:")) ) |
161 | slotwriteMail(QString::null, mail.mid(7)); | 154 | slotwriteMail(QString::null, mail.mid(7)); |
162 | } | 155 | } |
163 | 156 | ||
164 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 157 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
165 | { | 158 | { |
@@ -203,100 +196,101 @@ void OpieMail::slotSendQueued() | |||
203 | } | 196 | } |
204 | } | 197 | } |
205 | if (smtpList.count()==0) | 198 | if (smtpList.count()==0) |
206 | { | 199 | { |
207 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); | 200 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); |
208 | return; | 201 | return; |
209 | } | 202 | } |
210 | if (smtpList.count()==1) | 203 | if (smtpList.count()==1) |
211 | { | 204 | { |
212 | smtp = smtpList.at(0); | 205 | smtp = smtpList.at(0); |
213 | } | 206 | } |
214 | else | 207 | else |
215 | { | 208 | { |
216 | smtp = 0; | 209 | smtp = 0; |
217 | selectsmtp selsmtp; | 210 | selectsmtp selsmtp; |
218 | selsmtp.setSelectionlist(&smtpList); | 211 | selsmtp.setSelectionlist(&smtpList); |
219 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) | 212 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) |
220 | { | 213 | { |
221 | smtp = selsmtp.selected_smtp(); | 214 | smtp = selsmtp.selected_smtp(); |
222 | } | 215 | } |
223 | } | 216 | } |
224 | if (smtp) | 217 | if (smtp) |
225 | { | 218 | { |
226 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 219 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
227 | if ( wrap->flushOutbox() ) | 220 | if ( wrap->flushOutbox() ) |
228 | { | 221 | { |
229 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 222 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
230 | } | 223 | } |
231 | delete wrap; | 224 | delete wrap; |
232 | } | 225 | } |
233 | } | 226 | } |
234 | 227 | ||
235 | void OpieMail::slotSearchMails() | 228 | void OpieMail::slotSearchMails() |
236 | { | 229 | { |
237 | odebug << "Search Mails" << oendl; | 230 | odebug << "Search Mails" << oendl; |
238 | } | 231 | } |
239 | 232 | ||
240 | void OpieMail::slotEditSettings() | 233 | void OpieMail::slotEditSettings() |
241 | { | 234 | { |
242 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 235 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
243 | QPEApplication::execDialog( &settingsDialog ); | 236 | QPEApplication::execDialog( &settingsDialog ); |
244 | } | 237 | } |
245 | 238 | ||
246 | void OpieMail::slotEditAccounts() | 239 | void OpieMail::slotEditAccounts() |
247 | { | 240 | { |
248 | odebug << "Edit Accounts" << oendl; | 241 | odebug << "Edit Accounts" << oendl; |
249 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 242 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
250 | eaDialog.slotAdjustColumns(); | 243 | eaDialog.slotAdjustColumns(); |
251 | QPEApplication::execDialog( &eaDialog ); | 244 | if (QPEApplication::execDialog( &eaDialog )==QDialog::Rejected);// return; |
245 | |||
252 | if ( settings ) delete settings; | 246 | if ( settings ) delete settings; |
253 | settings = new Settings(); | 247 | settings = new Settings(); |
254 | 248 | mailView->clear(); | |
255 | folderView->populate( settings->getAccounts() ); | 249 | folderView->populate( settings->getAccounts() ); |
256 | } | 250 | } |
257 | 251 | ||
258 | void OpieMail::displayMail() | 252 | void OpieMail::displayMail() |
259 | { | 253 | { |
260 | QListViewItem*item = mailView->currentItem(); | 254 | QListViewItem*item = mailView->currentItem(); |
261 | if (!item) return; | 255 | if (!item) return; |
262 | RecMailP mail = ((MailListViewItem*)item)->data(); | 256 | RecMailP mail = ((MailListViewItem*)item)->data(); |
263 | RecBodyP body = folderView->fetchBody(mail); | 257 | RecBodyP body = folderView->fetchBody(mail); |
264 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 258 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
265 | readMail.setBody( body ); | 259 | readMail.setBody( body ); |
266 | readMail.setMail( mail ); | 260 | readMail.setMail( mail ); |
267 | readMail.showMaximized(); | 261 | readMail.showMaximized(); |
268 | readMail.exec(); | 262 | readMail.exec(); |
269 | 263 | ||
270 | if ( readMail.deleted ) | 264 | if ( readMail.deleted ) |
271 | { | 265 | { |
272 | folderView->refreshCurrent(); | 266 | folderView->refreshCurrent(); |
273 | } | 267 | } |
274 | else | 268 | else |
275 | { | 269 | { |
276 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); | 270 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); |
277 | } | 271 | } |
278 | } | 272 | } |
279 | 273 | ||
280 | void OpieMail::slotDeleteMail() | 274 | void OpieMail::slotDeleteMail() |
281 | { | 275 | { |
282 | if (!mailView->currentItem()) return; | 276 | if (!mailView->currentItem()) return; |
283 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 277 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
284 | 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 ) | 278 | 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 ) |
285 | { | 279 | { |
286 | mail->Wrapper()->deleteMail( mail ); | 280 | mail->Wrapper()->deleteMail( mail ); |
287 | folderView->refreshCurrent(); | 281 | folderView->refreshCurrent(); |
288 | } | 282 | } |
289 | } | 283 | } |
290 | 284 | ||
291 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 285 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
292 | { | 286 | { |
293 | if (!mailView->currentItem()) return; | 287 | if (!mailView->currentItem()) return; |
294 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 288 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
295 | /* just the RIGHT button - or hold on pda */ | 289 | /* just the RIGHT button - or hold on pda */ |
296 | if (button!=2) {return;} | 290 | if (button!=2) {return;} |
297 | odebug << "Event right/hold" << oendl; | 291 | odebug << "Event right/hold" << oendl; |
298 | if (!item) return; | 292 | if (!item) return; |
299 | QPopupMenu *m = new QPopupMenu(0); | 293 | QPopupMenu *m = new QPopupMenu(0); |
300 | if (m) | 294 | if (m) |
301 | { | 295 | { |
302 | if (mailtype==MAILLIB::A_NNTP) { | 296 | if (mailtype==MAILLIB::A_NNTP) { |