author | zautrix <zautrix> | 2005-02-28 15:30:47 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-28 15:30:47 (UTC) |
commit | 16575cca67c9047de72530080dfeb5793a66c935 (patch) (side-by-side diff) | |
tree | fec5ada5eee13fad9c73ec04cd066ccaf2619d4a /kmicromail | |
parent | b1f912cbb6a9daf050e94d337de0e0e73417284a (diff) | |
download | kdepimpi-16575cca67c9047de72530080dfeb5793a66c935.zip kdepimpi-16575cca67c9047de72530080dfeb5793a66c935.tar.gz kdepimpi-16575cca67c9047de72530080dfeb5793a66c935.tar.bz2 |
mail fix
-rw-r--r-- | kmicromail/accountview.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/smtpwrapper.cpp | 12 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 5 |
3 files changed, 15 insertions, 7 deletions
diff --git a/kmicromail/accountview.cpp b/kmicromail/accountview.cpp index 3ad3e9b..e9be224 100644 --- a/kmicromail/accountview.cpp +++ b/kmicromail/accountview.cpp @@ -52,130 +52,133 @@ void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; } void AccountView::populate( QList<Account> list ) { clear(); imapAccounts.clear(); mhAccounts.clear(); mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); Account *it; for ( it = list.first(); it; it = list.next() ) { if ( it->getType() == MAILLIB::A_IMAP ) { IMAPaccount *imap = static_cast<IMAPaccount *>(it); imapAccounts.append(new IMAPviewItem( imap, this )); } else if ( it->getType() == MAILLIB::A_POP3 ) { POP3account *pop3 = static_cast<POP3account *>(it); /* must not be hold 'cause it isn't required */ (void) new POP3viewItem( pop3, this ); } else if ( it->getType() == MAILLIB::A_NNTP ) { NNTPaccount *nntp = static_cast<NNTPaccount *>(it); /* must not be hold 'cause it isn't required */ (void) new NNTPviewItem( nntp, this ); } } } void AccountView::refresh(QListViewItem *item) { if ( item ) { m_currentItem = item; QValueList<RecMailP> headerlist; AccountViewItem *view = static_cast<AccountViewItem *>(item); view->refresh(headerlist); emit refreshMailview(headerlist); } } void AccountView::refreshOutgoing() { m_currentItem = currentItem(); if ( !m_currentItem ) return; AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); QString bName = view->getFolder()->getDisplayName(); if (bName.startsWith("/")&&bName.length()>1) { bName.replace(0,1,""); } int pos = bName.findRev("/"); if (pos > 0) { bName.replace(0,pos+1,""); } - if ( bName.lower() == "outgoing" ) + //qDebug("name *%s* ",bName.lower().latin1() ); + if ( bName.lower() == "outgoing" || bName.lower() == "sent" || bName.lower() == "sendfailed" ) { refreshCurrent(); + // qDebug("refresh "); + } } void AccountView::refreshCurrent() { m_currentItem = currentItem(); if ( !m_currentItem ) return; QValueList<RecMailP> headerlist; AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); view->refresh(headerlist); emit refreshMailview(headerlist); } void AccountView::refreshAll() { } RecBodyP AccountView::fetchBody(const RecMailP&aMail) { QListViewItem*item = selectedItem (); if (!item) return new RecBody(); AccountViewItem *view = static_cast<AccountViewItem *>(item); return view->fetchBody(aMail); } void AccountView::setupFolderselect(Selectstore*sels) { #ifndef DESKTOP_VERSION sels->showMaximized(); #else sels->show(); #endif QStringList sFolders; unsigned int i = 0; for (i=0; i < mhAccounts.count();++i) { mhAccounts[i]->refresh(false); sFolders = mhAccounts[i]->subFolders(); sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); } for (i=0; i < imapAccounts.count();++i) { if (imapAccounts[i]->offline()) continue; imapAccounts[i]->refreshFolders(false); sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); } } void AccountView::downloadMailsInbox(const FolderP&fromFolder,AbstractMail*fromWrapper) { #if 0 AbstractMail*targetMail = 0; QString targetFolder = ""; Selectstore sels; setupFolderselect(&sels); if (!sels.exec()) return; targetMail = sels.currentMail(); targetFolder = sels.currentFolder(); if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || targetFolder.isEmpty()) { return; } if (sels.newFolder() && !targetMail->createMbox(targetFolder)) diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp index 24f4786..5096f67 100644 --- a/kmicromail/libmailwrapper/smtpwrapper.cpp +++ b/kmicromail/libmailwrapper/smtpwrapper.cpp @@ -1,110 +1,111 @@ #include "smtpwrapper.h" #include "mailwrapper.h" #include "abstractmail.h" #include "logindialog.h" #include "mailtypes.h" #include "sendmailprogress.h" //#include <opie2/odebug.h> //#include <qt.h> #include <qapplication.h> #include <qmessagebox.h> #include <stdlib.h> #ifndef DESKTOP_VERSION //#include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #endif #include <libetpan/libetpan.h> #include <klocale.h> #include <kglobal.h> #include <kconfig.h> using namespace Opie::Core; progressMailSend*SMTPwrapper::sendProgress = 0; SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) : Generatemail() { m_SmtpAccount = aSmtp; KConfig cfg( locateLocal("config", "kopiemailrc" ) ); cfg.setGroup( "Status" ); m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); emit queuedMails( m_queuedMail ); connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); m_smtp = 0; } SMTPwrapper::~SMTPwrapper() { disc_server(); } void SMTPwrapper::emitQCop( int queued ) { #ifndef DESKTOP_VERSION - QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); - env << queued; + // LR : not used in kde-pim + //QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); + //env << queued; #endif } QString SMTPwrapper::mailsmtpError( int errnum ) { switch ( errnum ) { case MAILSMTP_NO_ERROR: return i18n( "No error" ); case MAILSMTP_ERROR_UNEXPECTED_CODE: return i18n( "Unexpected error code" ); case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: return i18n( "Service not available" ); case MAILSMTP_ERROR_STREAM: return i18n( "Stream error" ); case MAILSMTP_ERROR_HOSTNAME: return i18n( "gethostname() failed" ); case MAILSMTP_ERROR_NOT_IMPLEMENTED: return i18n( "Not implemented" ); case MAILSMTP_ERROR_ACTION_NOT_TAKEN: return i18n( "Error, action not taken" ); case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: return i18n( "Data exceeds storage allocation" ); case MAILSMTP_ERROR_IN_PROCESSING: return i18n( "Error in processing" ); case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: return i18n( "Starttls not supported" ); // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: // return i18n( "Insufficient system storage" ); case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: return i18n( "Mailbox unavailable" ); case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: return i18n( "Mailbox name not allowed" ); case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: return i18n( "Bad command sequence" ); case MAILSMTP_ERROR_USER_NOT_LOCAL: return i18n( "User not local" ); case MAILSMTP_ERROR_TRANSACTION_FAILED: return i18n( "Transaction failed" ); case MAILSMTP_ERROR_MEMORY: return i18n( "Memory error" ); case MAILSMTP_ERROR_CONNECTION_REFUSED: return i18n( "Connection refused" ); default: return i18n( "Unknown error code" ); } } void SMTPwrapper::progress( size_t current, size_t maximum ) { if (SMTPwrapper::sendProgress) { SMTPwrapper::sendProgress->setSingleMail(current, maximum ); qApp->processEvents(); } } void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { if (!mail) return; QString localfolders = AbstractMail::defaultLocalfolder(); AbstractMail*wrap = AbstractMail::getWrapper(localfolders); wrap->createMbox(box); wrap->storeMessage(mail,length,box); delete wrap; } @@ -380,91 +381,90 @@ int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { if (data) { delete data; } if (from) { free(from); } if (rcpts) { smtp_address_list_free( rcpts ); } return res; } /* this is a special fun */ bool SMTPwrapper::flushOutbox() { bool returnValue = true; ; // odebug << "Sending the queue" << oendl; if (!m_SmtpAccount) { ; // odebug << "No smtp account given" << oendl; return false; } bool reset_user_value = false; QString localfolders = AbstractMail::defaultLocalfolder(); AbstractMail*wrap = AbstractMail::getWrapper(localfolders); if (!wrap) { ; // odebug << "memory error" << oendl; return false; } QString oldPw, oldUser; QValueList<RecMailP> mailsToSend; QValueList<RecMailP> mailsToRemove; QString mbox("Outgoing"); wrap->listMessages(mbox,mailsToSend); if (mailsToSend.count()==0) { delete wrap; ; // odebug << "No mails to send" << oendl; return false; } oldPw = m_SmtpAccount->getPassword(); oldUser = m_SmtpAccount->getUser(); if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { // get'em QString user,pass; LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { // ok user = login.getUser().latin1(); pass = login.getPassword().latin1(); reset_user_value = true; m_SmtpAccount->setUser(user); m_SmtpAccount->setPassword(pass); } else { return true; } } sendProgress = new progressMailSend(); sendProgress->show(); sendProgress->setMaxMails(mailsToSend.count()); - while (mailsToSend.count()>0) { + while (returnValue && mailsToSend.count()>0) { if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { QMessageBox::critical(0,i18n("Error sending mail"), - i18n("Error sending queued mail - breaking")); + i18n("Error sending queued mail.\nBreaking.")); returnValue = false; - break; } mailsToRemove.append((*mailsToSend.begin())); mailsToSend.remove(mailsToSend.begin()); sendProgress->setCurrentMails(mailsToRemove.count()); } if (reset_user_value) { m_SmtpAccount->setUser(oldUser); m_SmtpAccount->setPassword(oldPw); } KConfig cfg( locateLocal("config", "kopiemailrc" ) ); cfg.setGroup( "Status" ); - m_queuedMail = 0; + m_queuedMail = mailsToSend.count(); cfg.writeEntry( "outgoing", m_queuedMail ); emit queuedMails( m_queuedMail ); sendProgress->hide(); delete sendProgress; sendProgress = 0; wrap->deleteMails(mbox,mailsToRemove); delete wrap; return returnValue; } diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index f68467c..197f7ec 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -82,154 +82,156 @@ void OpieMail::message(const QCString &msg, const QByteArray &data) if (msg == "writeMail(QString,QString)") { //qDebug("writeMail(QString,QString) "); QDataStream stream(data,IO_ReadOnly); stream >> mPendingName >> mPendingEmail; // removing the whitespaces at beginning and end is needed! QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); } else if (msg == "newMail()") { //qDebug("slotComposeMail() "); // we cannot call slotComposeMail(); directly, because may be executing a QCOP call // and a QCOP call does not like a processevents in his execution // with the Qtimer we call slotComposeMail() after we reached the main event loop QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); // slotComposeMail(); } else if (msg == "newMail(QString)") { //qDebug(" newMail(QString)"); QDataStream stream(data,IO_ReadOnly); stream >> mPendingName; // the format is // NAME <EMAIL>:SUBJECT QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); } else { mPendingData = data; mPendingMessage = msg; QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); } //qDebug("END OpieMail::message "); } void OpieMail::slotExtAppHandler() { ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); } void OpieMail::slotwriteMail2(const QString& namemail ) { //qDebug("OpieMail::slotwriteMail2 "); //qApp->processEvents(); ComposeMail compose( settings, this, 0, true ); if ( !namemail.isEmpty() ) { QString to = namemail; if ( namemail.find( " <") > 1 ) { to = "\"" +to.replace( QRegExp( " <"), "\" <") ; } else if ( namemail.find( "<") > 1 ) { to = "\"" +to.replace( QRegExp( "<"), "\" <") ; } int sub = to.find( ">:"); if ( sub > 0 ) { compose.setTo( to.left(sub+1) ); compose.setSubject( to.mid(sub+2) ); } else compose.setTo( to ); } compose.slotAdjustColumns(); #ifndef DESKTOP_VERSION compose.showMaximized(); #endif mCurrentComposer = &compose; compose.exec(); mCurrentComposer = 0; + folderView->refreshOutgoing(); raise(); //qDebug("retttich "); } void OpieMail::slotwriteMail(const QString&name,const QString&email) { // qDebug("OpieMail::slotwriteMail "); ComposeMail compose( settings, this, 0, true ); if (!email.isEmpty()) { if (!name.isEmpty()) { compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); } else { compose.setTo(email); } } compose.slotAdjustColumns(); #ifndef DESKTOP_VERSION compose.showMaximized(); #endif mCurrentComposer = &compose; compose.exec(); mCurrentComposer = 0; + folderView->refreshOutgoing(); raise(); } void OpieMail::slotComposeMail() { if ( mPendingEmail == QString::null && mPendingName == QString::null) slotwriteMail2( QString () ); else { if ( mPendingEmail == QString::null ) slotwriteMail2( mPendingName ); else slotwriteMail( mPendingName, mPendingEmail ); } //slotwriteMail(0l,0l); } void OpieMail::slotSendQueued() { SMTPaccount *smtp = 0; QList<Account> list = settings->getAccounts(); QList<SMTPaccount> smtpList; smtpList.setAutoDelete(false); Account *it; for ( it = list.first(); it; it = list.next() ) { if ( it->getType() == MAILLIB::A_SMTP ) { smtp = static_cast<SMTPaccount *>(it); smtpList.append(smtp); } } if (smtpList.count()==0) { QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); return; } if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) return; if (smtpList.count()==1) { smtp = smtpList.at(0); } else { smtp = 0; selectsmtp selsmtp; selsmtp.setSelectionlist(&smtpList); #ifndef DESKTOP_VERSION selsmtp.showMaximized(); #endif if ( selsmtp.exec() == QDialog::Accepted ) { smtp = selsmtp.selected_smtp(); } } if (smtp) { Global::statusMessage("Sending mails...!"); SMTPwrapper * wrap = new SMTPwrapper(smtp); if ( wrap->flushOutbox() ) { Global::statusMessage("Mails sent!"); @@ -253,128 +255,129 @@ void OpieMail::slotEditSettings() #endif settingsDialog.exec(); slotSetCodec( KOPrefs::instance()->mCurrentCodec ); // KApplication::execDialog(settingsDialog); } void OpieMail::slotEditAccounts() { EditAccounts eaDialog( settings, this, 0, true ); eaDialog.slotAdjustColumns(); #ifndef DESKTOP_VERSION eaDialog.showMaximized(); #endif eaDialog.exec(); if ( settings ) delete settings; settings = new Settings(); folderView->populate( settings->getAccounts() ); } void OpieMail::replyMail() { QListViewItem*item = mailView->currentItem(); if (!item) return; RecMailP mail = ((MailListViewItem*)item)->data(); RecBodyP body = folderView->fetchBody(mail); QString rtext; rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose .arg( mail->getFrom()) .arg( mail->getDate()); QString text = body->Bodytext(); QStringList lines = QStringList::split(QRegExp("\\n"), text); QStringList::Iterator it; for (it = lines.begin(); it != lines.end(); it++) { rtext += "> " + *it + "\n"; } rtext += "\n"; QString prefix; if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; else prefix = "Re: "; // no i18n on purpose Settings *settings = new Settings(); ComposeMail composer( settings ,this, 0, true); if (mail->Replyto().isEmpty()) { composer.setTo( mail->getFrom()); } else { composer.setTo( mail->Replyto()); } composer.setSubject( prefix + mail->getSubject()); composer.setMessage( rtext ); composer.setInReplyTo( mail->Msgid()); composer.setCharset( body->getCharset() ); mCurrentComposer = &composer; if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) { mail->Wrapper()->answeredMail(mail); } mCurrentComposer = 0; + folderView->refreshOutgoing(); delete settings; } void OpieMail::closeViewMail(ViewMail * vm) { vm->hide(); } void OpieMail::slotDownloadMail( ) { QListViewItem*item = mailView->currentItem(); if (!item ) { Global::statusMessage("Error: No item slected!"); return; } RecMailP mail = ((MailListViewItem*)item)->data(); Account * acc = mail->Wrapper()->getAccount(); if ( !acc ) { Global::statusMessage("Mail is already stored locally!"); return; } QString lfName = acc->getLocalFolder(); //qDebug("local folder " + lfName ); if ( lfName.isEmpty() ) lfName = acc->getAccountName(); AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); //qDebug("target %d %d ",targetMail,mail->Wrapper() ); if ( targetMail == mail->Wrapper() ) { Global::statusMessage("Mail is already locally stored!"); return; } if ( !targetMail->createMbox(lfName)) { Global::statusMessage("Error creating folder!"); return; } Global::statusMessage("Fetching mail...please wait!"); qApp->processEvents(); encodedString*st = 0; st = mail->Wrapper()->fetchRawBody(mail); if ( st ) { targetMail->storeMessage(st->Content(),st->Length(),lfName); Global::statusMessage("Mail stored in "+ lfName); delete st; } else { Global::statusMessage("Error: Cannot fetch mail!"); } } void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) { QListViewItem*item = mailView->currentItem(); if (!item ) { closeViewMail(vm); return; } RecMailP mail = ((MailListViewItem*)item)->data(); mail->Wrapper()->deleteMail( mail ); item = item->itemBelow(); if (!item ) { closeViewMail(vm); return; } mailView->setCurrentItem(item); @@ -588,85 +591,87 @@ void OpieMail::slotMoveCopyMail() // qDebug("hiding sels "); mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); folderView->refreshCurrent(); } void OpieMail::slotMoveCopyAllMail() { if (!mailView->currentItem()) return; QValueList<RecMailP> t; // 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 ) { MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); while ( item ) { if ( item->isSelected() ) { t.append( item->data() ); } item = (MailListViewItem*)item->nextSibling(); } } // else // return; if ( t.count() == 0 ) return; RecMailP mail = t.first(); AbstractMail*targetMail = 0; QString targetFolder = ""; Selectstore sels; folderView->setupFolderselect(&sels); if (!sels.exec()) return; targetMail = sels.currentMail(); targetFolder = sels.currentFolder(); if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || targetFolder.isEmpty()) { return; } if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { QMessageBox::critical(0,i18n("Error creating new Folder"), i18n("<center>Error while creating<br>new folder - breaking.</center>")); return; } sels.hide(); qApp->processEvents(); //qDebug("hiding sels "); mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); folderView->refreshCurrent(); } void OpieMail::reEditMail() { if (!mailView->currentItem()) return; ComposeMail compose( settings, this, 0, true ); compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); compose.slotAdjustColumns(); #ifndef DESKTOP_VERSION compose.showMaximized(); #else compose.resize(640,480); #endif mCurrentComposer = &compose; compose.exec(); + folderView->refreshOutgoing(); mCurrentComposer = 0; } void OpieMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) { if ( mCurrentComposer ) { mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); } else { ComposeMail compose( settings, this, 0, true ); compose.slotAdjustColumns(); #ifndef DESKTOP_VERSION compose.showMaximized(); #endif mCurrentComposer = &compose; mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); compose.exec(); mCurrentComposer = 0; + folderView->refreshOutgoing(); raise(); } } |