-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 154 | ||||
-rw-r--r-- | noncore/net/mailit/emailclient.h | 32 | ||||
-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mailit/mailitwindow.cpp | 40 | ||||
-rw-r--r-- | noncore/net/mailit/mailitwindow.h | 8 | ||||
-rw-r--r-- | noncore/net/mailit/readmail.cpp | 36 | ||||
-rw-r--r-- | noncore/net/mailit/readmail.h | 5 | ||||
-rw-r--r-- | noncore/net/mailit/writemail.cpp | 103 | ||||
-rw-r--r-- | noncore/net/mailit/writemail.h | 9 |
9 files changed, 361 insertions, 43 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 0d82a9a..ad1e0b4 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp @@ -58,10 +58,14 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) SLOT(smtpError(int)) ); connect(emailHandler, SIGNAL(popError(int)), this, SLOT(popError(int)) ); - connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); - connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); + connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); + connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); + + connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); + connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); + connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, SLOT(mailArrived(const Email &, bool)) ); connect(emailHandler, SIGNAL(mailTransfered(int)), this, @@ -142,12 +146,28 @@ void EmailClient::init() configure->insertItem(tr("Delete account"), deleteAccountMenu); bar = new QToolBar(this); - getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); + getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); + //connect(setAccountlButton, SIGNAL(activated()), this, SLOT(setCurrentAccount()) ); + // setAccountButton->addTo(bar); + //setAccountButton->addTo(mail); + + /*idCount = 0; + + for (MailAccount* accountPtr = accountList.first(); accountPtr != 0; + accountPtr = accountList.next()) { + + selectAccountMenu->insertItem(accountPtr->accountName,this, SLOT(selectAccount(int)), 0, idCount); + idCount++; + }*/ + getMailButton->setPopup(selectAccountMenu); + + + /*getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); - getMailButton->addTo(bar); - getMailButton->addTo(mail); + getMailButton->addTo(bar);*/ + //getMailButton->addTo(mail); sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); sendMailButton->addTo(bar); @@ -163,8 +183,12 @@ void EmailClient::init() cancelButton->addTo(mail); cancelButton->addTo(bar); cancelButton->setEnabled(FALSE); + deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); + connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); + deleteButton->addTo(bar); + mailboxView = new OTabWidget( this, "mailboxView" ); QWidget* widget = new QWidget( mailboxView, "widget" ); grid_2 = new QGridLayout( widget ); @@ -194,8 +218,10 @@ void EmailClient::init() grid_3->addWidget( outboxView, 0, 0 ); mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); setCentralWidget(mailboxView); + + mailboxView->setCurrentTab(0); } void EmailClient::compose() { @@ -231,8 +257,10 @@ void EmailClient::enqueMail(const Email &mail) addMail.fromMail = currentAccount->emailAddress; addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); item = new EmailListItem(outboxView, addMail, false); + mailboxView->setCurrentTab(1); + } void EmailClient::sendQuedMail() { @@ -295,18 +323,18 @@ void EmailClient::getNewMail() { status1Label->setText(currentAccount->accountName + " headers"); progressBar->reset(); //get any previous mails not downloaded and add to queue - mailDownloadList.clear(); +/* mailDownloadList.clear(); Email *mailPtr; item = (EmailListItem *) inboxView->firstChild(); while (item != NULL) { mailPtr = item->getMail(); if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); } item = (EmailListItem *) item->nextSibling(); - } + }*/ emailHandler->getMailHeaders(); } @@ -414,8 +442,10 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) if (!newMail.downloaded) mailDownloadList.sizeInsert(newMail.serverId, newMail.size); } + mailboxView->setCurrentTab(0); + } void EmailClient::allMailArrived(int count) { @@ -443,8 +473,10 @@ void EmailClient::allMailArrived(int count) status1Label->setText(currentAccount->accountName); progressBar->reset(); emailHandler->getMailByList(&mailDownloadList); + + mailboxView->setCurrentTab(0); } void EmailClient::moveMailFront(Email *mailPtr) { @@ -508,16 +540,20 @@ void EmailClient::popError(int code) } void EmailClient::inboxItemSelected() { + killTimer(timerID); + item = (EmailListItem*) inboxView->selectedItem(); if (item != NULL) { emit viewEmail(inboxView, item->getMail()); } } void EmailClient::outboxItemSelected() { + killTimer(timerID); + item = (EmailListItem*) outboxView->selectedItem(); if (item != NULL) { emit viewEmail(outboxView, item->getMail()); } @@ -691,8 +727,9 @@ void EmailClient::readSettings() } void EmailClient::saveSettings() { + QString temp; QFile f( getPath(FALSE) + "settings.txt"); MailAccount *accountPtr; @@ -700,9 +737,9 @@ void EmailClient::saveSettings() qWarning("could not save settings file"); return; } QTextStream t(&f); - t << "#Settings for QPE Mailit program\n"; + t << "#Settings for OPIE Mailit program\n"; for (accountPtr = accountList.first(); accountPtr != 0; accountPtr = accountList.next()) { @@ -810,9 +847,9 @@ void EmailClient::updateAccounts() accountPtr = accountList.next()) { editAccountMenu->insertItem(accountPtr->accountName, this, SLOT(editAccount(int)), 0, idCount); - selectAccountMenu->insertItem(accountPtr->accountName, + selectAccountMenu->insertItem(accountPtr->accountName, this, SLOT(selectAccount(int)), 0, idCount); deleteAccountMenu->insertItem(accountPtr->accountName, this, SLOT(deleteAccount(int)), 0, idCount); idCount++; @@ -823,9 +860,10 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) { Email *mPtr; Enclosure *ePtr; - if (inbox) { + if (inbox) + { mPtr = mailItem->getMail(); //if mail is in queue for download, remove it from //queue if possible @@ -843,9 +881,11 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) QFile::remove( (ePtr->path + ePtr->name) ); } } inboxView->takeItem(mailItem); - } else { + } + else + { outboxView->takeItem(mailItem); } } @@ -869,4 +909,96 @@ void EmailClient::setDownloadedSize(int size) } else { progressBar->setProgress(total); } } + +void EmailClient::deleteItem() +{ + bool inbox=mailboxView->currentTab()==0; + + EmailListItem* eli; + + inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); + + if (eli) + deleteMail(eli,(bool&)inbox); +} + +void EmailClient::inboxItemPressed() +{ +// timerID=startTimer(500); +} + +void EmailClient::inboxItemReleased() +{ + // killTimer(timerID); +} + +void EmailClient::timerEvent(QTimerEvent *e) +{ + /*killTimer(timerID); + + + QPopupMenu *action = new QPopupMenu(this); + + int reply=0; + + action->insertItem(tr( "Reply To" ),this,SLOT(reply())); + action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); + action->insertItem( tr( "Forward" ), this,SLOT(forward())); + action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); + + action->exec(QCursor::pos()); + + if (action) delete action; + */ +} + +Email* EmailClient::getCurrentMail() +{ + EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); + if (eli!=NULL) + return eli->getMail(); + else + return NULL; +} + +/* +void EmailClient::reply() +{ + Email* mail=getCurrentMail(); + + if (mail!=NULL) + { + emit reply(*mail); + } +} + +void EmailClient::replyAll() +{ + Email* mail=getCurrentMail(); + + if (mail!=NULL) + { + emit replyAll(*mail); + } +} + +void EmailClient::forward() +{ + Email* mail=getCurrentMail(); + + if (mail!=NULL) + { + emit reply(*mail); + } +} + +void EmailClient::remove() +{ + Email* mail=getCurrentMail(); + + if (mail!=NULL) + { + emit remove(*mail); + } +}*/
\ No newline at end of file diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h index 80457f9..0890dcf 100644 --- a/noncore/net/mailit/emailclient.h +++ b/noncore/net/mailit/emailclient.h @@ -31,16 +31,18 @@ #include <qlistview.h> #include <qaction.h> #include <qlayout.h> #include <qtooltip.h> +#include <qtoolbutton.h> #include <qimage.h> #include <qpixmap.h> #include <qstringlist.h> #include <qprogressbar.h> #include <qstatusbar.h> #include <qdir.h> #include <stdlib.h> #include <opie/otabwidget.h> +#include <qtimer.h> #include "emailhandler.h" #include "emaillistitem.h" #include "textparser.h" @@ -68,27 +70,40 @@ public: EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); ~EmailClient(); AddressList* getAdrListRef(); +protected: + void timerEvent(QTimerEvent*); + signals: void composeRequested(); void viewEmail(QListView *, Email *); void mailUpdated(Email *); void newCaption(const QString &); - + void replyRequested(Email&, bool&); + void forwardRequested(Email&); + void removeItem(EmailListItem*, bool&); + /*void reply(Email&); + void replyAll(Email&); + void remove(Email&); + void forward(Email&);*/ + public slots: void compose(); void cancel(); void enqueMail(const Email &mail); void setMailAccount(); void sendQuedMail(); void mailSent(); + void deleteItem(); void getNewMail(); void getAllNewMail(); void smtpError(int code); void popError(int code); void inboxItemSelected(); void outboxItemSelected(); + void inboxItemPressed(); + void inboxItemReleased(); void mailArrived(const Email &mail, bool fromDisk); void allMailArrived(int); void saveMail(QString fileName, QListView *view); void selectAccount(int); @@ -99,17 +114,21 @@ public slots: void setTotalSize(int); void setMailSize(int); void setDownloadedSize(int); void moveMailFront(Email *mailPtr); +/* void reply(); + void replyAll(); + void forward(); + void remove();*/ private: void init(); void readMail(); QString getPath(bool enclosurePath); void readSettings(); void saveSettings(); - -private: + Email* getCurrentMail(); + int timerID; Config *mailconf; int newAccountId, idCount, mailIdCount; int accountIdCount; AccountList accountList; @@ -127,17 +146,20 @@ private: QToolBar *bar; QProgressBar *progressBar; QStatusBar *statusBar; QLabel *status1Label, *status2Label; - QAction *getMailButton; + QToolButton *getMailButton; QAction *sendMailButton; QAction *composeButton; QAction *cancelButton; - + QAction *deleteButton; + //QToolButton *setAccountButton; + QMenuBar *mb; QPopupMenu *selectAccountMenu; QPopupMenu *editAccountMenu; QPopupMenu *deleteAccountMenu; + QPopupMenu *setAccountMenu; OTabWidget* mailboxView; QListView* inboxView; QListView* outboxView; diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index 03f8a28..f6c6d60 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp @@ -199,15 +199,21 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail) } } //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: - if (pos = p.find("TO",':', pos, TRUE) != -1) + if ((pos = p.find("TO",':', 0, TRUE)) != -1) { pos++; mail->recipients.append (p.getString(&pos, 'z', TRUE) ); } - + //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: + if ((pos = p.find("CC",':', 0, TRUE)) != -1) + { + pos++; + mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); + } + if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { pos++; mail->subject = p.getString(&pos, 'z', TRUE); @@ -433,8 +439,15 @@ int EmailHandler::encodeMime(Email *mail) newBody = "From: " + userName + "\r\nTo: "; for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { newBody += *it + " "; } + + newBody += "\r\nCC: "; + + for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { + newBody += *it + " "; + } + newBody += "\r\nSubject: " + mail->subject + "\r\n"; if (mail->files.count() == 0) { //just a simple mail newBody += "\r\n" + mail->body; diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp index 2bf1dcb..ef5fc09 100644 --- a/noncore/net/mailit/mailitwindow.cpp +++ b/noncore/net/mailit/mailitwindow.cpp @@ -46,10 +46,13 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, SLOT(enqueMail(const Email &)) ); connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); - connect(readMail, SIGNAL(replyRequested(Email &)), this, - SLOT(composeReply(Email &)) ); + connect(readMail, SIGNAL(replyRequested(Email &, bool&)), this, + SLOT(composeReply(Email &, bool&)) ); + connect(readMail, SIGNAL(forwardRequested(Email &)), this, + SLOT(composeForward(Email &)) ); + connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, SLOT(deleteMail(EmailListItem *, bool &)) ); connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, SLOT(moveMailFront(Email *)) ); @@ -82,14 +85,21 @@ void MailItWindow::compose() writeMail->setAddressList(emailClient->getAdrListRef()); setCaption( tr( "Write mail" ) ); } -void MailItWindow::composeReply(Email &mail) +void MailItWindow::composeReply(Email &mail, bool& replyAll) +{ + compose(); + writeMail->reply(mail,replyAll) ; +} + +void MailItWindow::composeForward(Email &mail) { compose(); - writeMail->reply(mail); + writeMail->forward(mail) ; } + void MailItWindow::showEmailClient() { viewingMail = FALSE; writeMail->hide(); @@ -130,4 +140,26 @@ void MailItWindow::setDocument(const QString &_address) compose(); writeMail->setRecipient(address); } +/*void MailItWindow::reply(Email& mail) +{ + qDebug("####EmailClient: 0 reached"); + composeReply(mail,(bool&)FALSE); +} + +void MailItWindow::replyAll(Email& mail) +{ + qDebug("####EmailClient: 1 reached"); + composeReply(mail,(bool&)TRUE); +} + +void MailItWindow::forward(Email& mail) +{ + qDebug("####EmailClient: 2 reached"); +} + +void MailItWindow::remove(Email&) +{ + qDebug("####EmailClient: 3 reached"); + //emit removeItem(eli,(bool&)TRUE); +} */
\ No newline at end of file diff --git a/noncore/net/mailit/mailitwindow.h b/noncore/net/mailit/mailitwindow.h index 667960b..e818d32 100644 --- a/noncore/net/mailit/mailitwindow.h +++ b/noncore/net/mailit/mailitwindow.h @@ -35,17 +35,23 @@ class MailItWindow: public QMainWindow public: MailItWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); ~MailItWindow(); +signals: public slots: void compose(); - void composeReply(Email &); + void composeReply(Email &, bool&); + void composeForward(Email &); void showEmailClient(); void viewMail(QListView *, Email *mail); void updateMailView(Email *mail); void closeEvent(QCloseEvent *e); void updateCaption(const QString &); void setDocument(const QString &); + /*void reply(Email&); + void replyAll(Email&); + void forward(Email&); + void remove(Email&);*/ private: EmailClient *emailClient; WriteMail *writeMail; diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp index 7cd3e09..dc98a6f 100644 --- a/noncore/net/mailit/readmail.cpp +++ b/noncore/net/mailit/readmail.cpp @@ -58,9 +58,13 @@ void ReadMail::init() //reply dependant on viewing inbox replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), QString::null, 0, this, 0 ); connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); - + + forwardButton = new QAction( tr( "Forward" ), Resource::loadPixmap( "mailit/forward" ), + QString::null, 0, this, 0 ); + connect(forwardButton, SIGNAL(activated()), this, SLOT(forward()) ); + previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); previousButton->addTo(bar); previousButton->addTo(viewMenu); @@ -106,13 +110,18 @@ void ReadMail::updateView() inbox = mail->received; replyButton->removeFrom(mailMenu); replyButton->removeFrom(bar); + forwardButton->removeFrom(mailMenu); + forwardButton->removeFrom(bar); if (inbox == TRUE) { replyButton->addTo(bar); replyButton->addTo(mailMenu); - + forwardButton->addTo(bar); + forwardButton->addTo(mailMenu); + + if (!mail->downloaded) { //report currently viewed mail so that it will be //placed first in the queue of new mails to download emit viewingMail(mail); @@ -144,8 +153,15 @@ void ReadMail::updateView() for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { text += *it + " "; } + + text +="<br><b>CC: </b>"; + for (QStringList::Iterator it = mail->carbonCopies.begin(); + it != mail->carbonCopies.end(); ++it ) { + text += *it + " "; + } + text += "<br>" + mail->date; if (mail->files.count() > 0) { text += "<br><b>Attatchments: </b>"; @@ -201,8 +217,16 @@ void ReadMail::updateView() for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { text += *it + " "; } + + text += "\nCC: "; + for (QStringList::Iterator it = mail->carbonCopies.begin(); + it != mail->carbonCopies.end(); ++it ) { + text += *it + " "; + } + + text += "\nDate: " + mail->date + "\n"; if (mail->files.count() > 0) { text += "Attatchments: "; for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { @@ -322,6 +346,12 @@ void ReadMail::viewAttatchments() } void ReadMail::reply() { - emit replyRequested(*mail); + emit replyRequested(*mail, (bool&)TRUE); } + +void ReadMail::forward() +{ + emit forwardRequested(*mail); +} + diff --git a/noncore/net/mailit/readmail.h b/noncore/net/mailit/readmail.h index d0bb067..0fe0646 100644 --- a/noncore/net/mailit/readmail.h +++ b/noncore/net/mailit/readmail.h @@ -45,9 +45,10 @@ public: void mailUpdated(Email *mailIn); signals: void cancelView(); - void replyRequested(Email &); + void replyRequested(Email &, bool &); + void forwardRequested(Email&); void removeItem(EmailListItem *, bool &); void viewingMail(Email *); public slots: @@ -57,8 +58,9 @@ public slots: void deleteItem(); void shiftText(); void viewAttatchments(); void reply(); + void forward(); private: void init(); void updateButtons(); @@ -80,7 +82,8 @@ private: QTextView *emailView; QAction *attatchmentsButton; QAction *previousButton; QAction *replyButton; + QAction *forwardButton; }; #endif // READMAIL_H diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp index 38a2596..a9dcb02 100644 --- a/noncore/net/mailit/writemail.cpp +++ b/noncore/net/mailit/writemail.cpp @@ -82,11 +82,13 @@ void WriteMail::init() grid = new QGridLayout( widget ); recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); recipientsBox->insertItem( tr( "To:" ) ); - recipientsBox->insertItem( tr( "CC:" ) ); + recipientsBox->insertItem( tr( "CC:" ) ); recipientsBox->setCurrentItem(0); grid->addWidget( recipientsBox, 0, 0 ); + connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); + subjetLabel = new QLabel( widget, "subjetLabel" ); subjetLabel->setText( tr( "Subject:" ) ); @@ -101,8 +103,13 @@ void WriteMail::init() toInput = new QLineEdit( widget, "toInput" ); grid->addWidget( toInput, 0, 1 ); + ccInput = new QLineEdit( widget, "ccInput" ); + ccInput->hide(); + grid->addWidget( ccInput, 0, 1 ); + + addressButton = new QToolButton( widget, "addressButton" ); addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); addressButton->setToggleButton(TRUE); grid->addWidget( addressButton, 0, 2 ); @@ -138,30 +145,53 @@ void WriteMail::accept() { QStringList attatchedFiles, attatchmentsType; int idCount = 0; - if (toInput->text() == "") { - QMessageBox::warning(this,"No recipient", "Send mail to whom?", "OK\n"); + if (toInput->text() == "") + { + QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); + return; + } + + if (! getRecipients(false) ) + { + QMessageBox::warning(this,tr("Incorrect recipient separator"), + tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); return; } - if (! getRecipients() ) { - QMessageBox::warning(this,"Incorrect recipient separator", - "Recipients must be separated by ;\nand be valid emailaddresses", "OK\n"); + + if ((ccInput->text()!="") && (! getRecipients(true) )) + { + QMessageBox::warning(this,tr("Incorrect carbon copy separator"), + tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); return; } + mail.subject = subjectInput->text(); mail.body = emailInput->text(); mail.sent = false; mail.received = false; + mail.rawMail = "To: "; for (QStringList::Iterator it = mail.recipients.begin(); it != mail.recipients.end(); ++it) { mail.rawMail += (*it); mail.rawMail += ",\n"; } + mail.rawMail.truncate(mail.rawMail.length()-2); + + mail.rawMail += "\nCC: "; + + for (QStringList::Iterator it = mail.carbonCopies.begin(); + it != mail.carbonCopies.end(); ++it) { + + mail.rawMail += (*it); + mail.rawMail += ",\n"; + } + mail.rawMail += mail.from; mail.rawMail += "\nSubject: "; mail.rawMail += mail.subject; mail.rawMail += "\n\n"; @@ -210,17 +240,21 @@ void WriteMail::attatchFile() { addAtt->showMaximized(); } -void WriteMail::reply(Email replyMail) +void WriteMail::reply(Email replyMail, bool replyAll) { int pos; mail = replyMail; mail.files.clear(); toInput->setText(mail.fromMail); - subjectInput->setText("Re: " + mail.subject); + //replyAll ? ccInput->setText(mail.c) + + addRecipients(replyAll); + + subjectInput->setText(tr("Re: ") + mail.subject); pos = 0; mail.body.insert(pos, ">>"); while (pos != -1) { @@ -231,39 +265,65 @@ void WriteMail::reply(Email replyMail) emailInput->setText(mail.body); } -bool WriteMail::getRecipients() +void WriteMail::forward(Email forwMail) +{ + int pos=0; + + QString fwdBody=tr("======forwarded message from "); + fwdBody.append(forwMail.fromMail); + fwdBody.append(tr(" starts======\n\n")); + + mail=forwMail; + toInput->setText(""); + ccInput->setText(""); + subjectInput->setText(tr("FWD: ") + mail.subject); + + fwdBody+=mail.body; + fwdBody+=QString(tr("======end of forwarded message======\n\n")); + + emailInput->setText(fwdBody); +} + +bool WriteMail::getRecipients(bool ccField) { QString str, temp; int pos = 0; mail.recipients.clear(); - temp = toInput->text(); + ccField ? temp = ccInput->text() : temp=toInput->text() ; + while ( (pos = temp.find(';')) != -1) { str = temp.left(pos).stripWhiteSpace(); temp = temp.right(temp.length() - (pos + 1)); if ( str.find('@') == -1) return false; - mail.recipients.append(str); + ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); addressList->addContact(str, ""); } temp = temp.stripWhiteSpace(); if ( temp.find('@') == -1) return false; - mail.recipients.append(temp); + ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); addressList->addContact(temp, ""); return TRUE; } - void WriteMail::addRecipients() { + + addRecipients(false); +} + +void WriteMail::addRecipients(bool ccField) +{ QString recipients = ""; mail.recipients.clear(); + QListViewItem *item = addressView->firstChild(); while (item != NULL) { if ( item->isSelected() ) { if (recipients == "") { @@ -273,17 +333,32 @@ void WriteMail::addRecipients() } } item = item->nextSibling(); } - toInput->setText(recipients); + + ccField ? ccInput->setText(recipients):toInput->setText(recipients); addressView->hide(); okButton->hide(); emailInput->show(); addressButton->setOn(FALSE); showingAddressList = !showingAddressList; } +void WriteMail::changeRecipients(int selection) +{ + if (selection==0) + { + toInput->show(); + ccInput->hide(); + } + else if (selection==1) + { + toInput->hide(); + ccInput->show(); + } +} + void WriteMail::setRecipient(const QString &recipient) { toInput->setText(recipient); } diff --git a/noncore/net/mailit/writemail.h b/noncore/net/mailit/writemail.h index dd12063..f193b13 100644 --- a/noncore/net/mailit/writemail.h +++ b/noncore/net/mailit/writemail.h @@ -42,27 +42,31 @@ class WriteMail : public QMainWindow public: WriteMail( QWidget* parent, const char* name, WFlags fl = 0 ); ~WriteMail(); - void reply(Email replyMail); + void reply(Email replyMail, bool replyAll); void setRecipient(const QString &recipient); void setAddressList(AddressList *list); + void forward(Email forwMail); signals: void sendMailRequested(const Email &mail); void cancelMail(); + public slots: void getAddress(); void attatchFile(); void addRecipients(); void newMail(); void accept(); void reject(); + void changeRecipients(int); private: - bool getRecipients(); + bool getRecipients(bool); void init(); + void addRecipients(bool); Email mail; AddAtt *addAtt; AddressList *addressList; @@ -82,8 +86,9 @@ private: QToolButton* ToolButton13_2; QComboBox* recipientsBox; QLineEdit *subjectInput; QLineEdit *toInput; + QLineEdit *ccInput; QToolButton* addressButton; QMultiLineEdit* emailInput; QGridLayout* grid; }; |