-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 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 154 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.h | 32 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailhandler.cpp | 17 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailitwindow.cpp | 40 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailitwindow.h | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/readmail.cpp | 36 | ||||
-rw-r--r-- | noncore/unsupported/mailit/readmail.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/mailit/writemail.cpp | 103 | ||||
-rw-r--r-- | noncore/unsupported/mailit/writemail.h | 9 |
18 files changed, 722 insertions, 86 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 @@ -61,4 +61,8 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) - 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()) ); + @@ -145,6 +149,22 @@ void EmailClient::init() - 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); @@ -166,2 +186,6 @@ void EmailClient::init() + 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" ); @@ -197,2 +221,4 @@ void EmailClient::init() setCentralWidget(mailboxView); + + mailboxView->setCurrentTab(0); } @@ -234,2 +260,4 @@ void EmailClient::enqueMail(const Email &mail) + mailboxView->setCurrentTab(1); + } @@ -298,3 +326,3 @@ void EmailClient::getNewMail() { //get any previous mails not downloaded and add to queue - mailDownloadList.clear(); +/* mailDownloadList.clear(); Email *mailPtr; @@ -307,3 +335,3 @@ void EmailClient::getNewMail() { item = (EmailListItem *) item->nextSibling(); - } + }*/ @@ -417,2 +445,4 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) + mailboxView->setCurrentTab(0); + } @@ -446,2 +476,4 @@ void EmailClient::allMailArrived(int count) emailHandler->getMailByList(&mailDownloadList); + + mailboxView->setCurrentTab(0); } @@ -511,2 +543,4 @@ void EmailClient::inboxItemSelected() { + killTimer(timerID); + item = (EmailListItem*) inboxView->selectedItem(); @@ -519,2 +553,4 @@ void EmailClient::outboxItemSelected() { + killTimer(timerID); + item = (EmailListItem*) outboxView->selectedItem(); @@ -694,2 +730,3 @@ void EmailClient::saveSettings() { + QString temp; @@ -703,3 +740,3 @@ void EmailClient::saveSettings() QTextStream t(&f); - t << "#Settings for QPE Mailit program\n"; + t << "#Settings for OPIE Mailit program\n"; @@ -813,3 +850,3 @@ void EmailClient::updateAccounts() this, SLOT(editAccount(int)), 0, idCount); - selectAccountMenu->insertItem(accountPtr->accountName, + selectAccountMenu->insertItem(accountPtr->accountName, this, SLOT(selectAccount(int)), 0, idCount); @@ -826,3 +863,4 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) - if (inbox) { + if (inbox) + { mPtr = mailItem->getMail(); @@ -846,3 +884,5 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) inboxView->takeItem(mailItem); - } else { + } + else + { outboxView->takeItem(mailItem); @@ -872 +912,93 @@ void EmailClient::setDownloadedSize(int size) } + +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 @@ -34,2 +34,3 @@ #include <qtooltip.h> +#include <qtoolbutton.h> #include <qimage.h> @@ -42,2 +43,3 @@ #include <opie/otabwidget.h> +#include <qtimer.h> @@ -71,2 +73,5 @@ public: +protected: + void timerEvent(QTimerEvent*); + signals: @@ -76,3 +81,10 @@ signals: 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: @@ -84,2 +96,3 @@ public slots: void mailSent(); + void deleteItem(); void getNewMail(); @@ -90,2 +103,4 @@ public slots: void outboxItemSelected(); + void inboxItemPressed(); + void inboxItemReleased(); void mailArrived(const Email &mail, bool fromDisk); @@ -102,2 +117,6 @@ public slots: void moveMailFront(Email *mailPtr); +/* void reply(); + void replyAll(); + void forward(); + void remove();*/ @@ -109,4 +128,4 @@ private: void saveSettings(); - -private: + Email* getCurrentMail(); + int timerID; Config *mailconf; @@ -130,3 +149,3 @@ private: QLabel *status1Label, *status2Label; - QAction *getMailButton; + QToolButton *getMailButton; QAction *sendMailButton; @@ -134,3 +153,5 @@ private: QAction *cancelButton; - + QAction *deleteButton; + //QToolButton *setAccountButton; + QMenuBar *mb; @@ -139,2 +160,3 @@ private: QPopupMenu *deleteAccountMenu; + QPopupMenu *setAccountMenu; 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 @@ -202,3 +202,3 @@ 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) { @@ -208,3 +208,9 @@ 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("CC",':', 0, TRUE)) != -1) + { + pos++; + mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); + } + @@ -436,2 +442,9 @@ int EmailHandler::encodeMime(Email *mail) } + + newBody += "\r\nCC: "; + + for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { + newBody += *it + " "; + } + newBody += "\r\nSubject: " + mail->subject + "\r\n"; 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 @@ -49,4 +49,7 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 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, @@ -85,8 +88,15 @@ void MailItWindow::compose() -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() @@ -133 +143,23 @@ void MailItWindow::setDocument(const QString &_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 @@ -38,5 +38,7 @@ public: +signals: public slots: void compose(); - void composeReply(Email &); + void composeReply(Email &, bool&); + void composeForward(Email &); void showEmailClient(); @@ -47,2 +49,6 @@ public slots: void setDocument(const QString &); + /*void reply(Email&); + void replyAll(Email&); + void forward(Email&); + void remove(Email&);*/ 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 @@ -61,3 +61,7 @@ void ReadMail::init() 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 ); @@ -109,2 +113,4 @@ void ReadMail::updateView() replyButton->removeFrom(bar); + forwardButton->removeFrom(mailMenu); + forwardButton->removeFrom(bar); @@ -113,3 +119,6 @@ void ReadMail::updateView() replyButton->addTo(mailMenu); - + forwardButton->addTo(bar); + forwardButton->addTo(mailMenu); + + if (!mail->downloaded) { @@ -147,2 +156,9 @@ void ReadMail::updateView() } + + text +="<br><b>CC: </b>"; + for (QStringList::Iterator it = mail->carbonCopies.begin(); + it != mail->carbonCopies.end(); ++it ) { + text += *it + " "; + } + text += "<br>" + mail->date; @@ -204,2 +220,10 @@ void ReadMail::updateView() } + + text += "\nCC: "; + for (QStringList::Iterator it = mail->carbonCopies.begin(); + it != mail->carbonCopies.end(); ++it ) { + text += *it + " "; + } + + text += "\nDate: " + mail->date + "\n"; @@ -325,3 +349,9 @@ 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 @@ -48,3 +48,4 @@ signals: void cancelView(); - void replyRequested(Email &); + void replyRequested(Email &, bool &); + void forwardRequested(Email&); void removeItem(EmailListItem *, bool &); @@ -60,2 +61,3 @@ public slots: void reply(); + void forward(); @@ -83,2 +85,3 @@ private: QAction *replyButton; + QAction *forwardButton; }; 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 @@ -85,5 +85,7 @@ void WriteMail::init() 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))); + @@ -104,2 +106,7 @@ void WriteMail::init() + ccInput = new QLineEdit( widget, "ccInput" ); + ccInput->hide(); + grid->addWidget( ccInput, 0, 1 ); + + addressButton = new QToolButton( widget, "addressButton" ); @@ -141,11 +148,22 @@ void WriteMail::accept() - 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(); @@ -154,2 +172,3 @@ void WriteMail::accept() mail.received = false; + mail.rawMail = "To: "; @@ -162,3 +181,14 @@ void WriteMail::accept() } + 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; @@ -213,3 +243,3 @@ void WriteMail::attatchFile() -void WriteMail::reply(Email replyMail) +void WriteMail::reply(Email replyMail, bool replyAll) { @@ -221,3 +251,7 @@ void WriteMail::reply(Email replyMail) toInput->setText(mail.fromMail); - subjectInput->setText("Re: " + mail.subject); + //replyAll ? ccInput->setText(mail.c) + + addRecipients(replyAll); + + subjectInput->setText(tr("Re: ") + mail.subject); @@ -234,3 +268,22 @@ void WriteMail::reply(Email replyMail) -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) { @@ -241,3 +294,4 @@ bool WriteMail::getRecipients() - temp = toInput->text(); + ccField ? temp = ccInput->text() : temp=toInput->text() ; + while ( (pos = temp.find(';')) != -1) { @@ -247,3 +301,3 @@ bool WriteMail::getRecipients() return false; - mail.recipients.append(str); + ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); addressList->addContact(str, ""); @@ -253,3 +307,3 @@ bool WriteMail::getRecipients() return false; - mail.recipients.append(temp); + ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); addressList->addContact(temp, ""); @@ -258,3 +312,2 @@ bool WriteMail::getRecipients() } - @@ -262,2 +315,8 @@ void WriteMail::addRecipients() { + + addRecipients(false); +} + +void WriteMail::addRecipients(bool ccField) +{ QString recipients = ""; @@ -265,2 +324,3 @@ void WriteMail::addRecipients() mail.recipients.clear(); + QListViewItem *item = addressView->firstChild(); @@ -276,3 +336,4 @@ void WriteMail::addRecipients() } - toInput->setText(recipients); + + ccField ? ccInput->setText(recipients):toInput->setText(recipients); @@ -285,2 +346,16 @@ void WriteMail::addRecipients() +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) 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 @@ -45,5 +45,6 @@ public: ~WriteMail(); - void reply(Email replyMail); + void reply(Email replyMail, bool replyAll); void setRecipient(const QString &recipient); void setAddressList(AddressList *list); + void forward(Email forwMail); @@ -52,2 +53,3 @@ signals: void cancelMail(); + @@ -60,6 +62,8 @@ public slots: void reject(); + void changeRecipients(int); private: - bool getRecipients(); + bool getRecipients(bool); void init(); + void addRecipients(bool); @@ -85,2 +89,3 @@ private: QLineEdit *toInput; + QLineEdit *ccInput; QToolButton* addressButton; diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 0d82a9a..ad1e0b4 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp @@ -61,4 +61,8 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) - 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()) ); + @@ -145,6 +149,22 @@ void EmailClient::init() - 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); @@ -166,2 +186,6 @@ void EmailClient::init() + 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" ); @@ -197,2 +221,4 @@ void EmailClient::init() setCentralWidget(mailboxView); + + mailboxView->setCurrentTab(0); } @@ -234,2 +260,4 @@ void EmailClient::enqueMail(const Email &mail) + mailboxView->setCurrentTab(1); + } @@ -298,3 +326,3 @@ void EmailClient::getNewMail() { //get any previous mails not downloaded and add to queue - mailDownloadList.clear(); +/* mailDownloadList.clear(); Email *mailPtr; @@ -307,3 +335,3 @@ void EmailClient::getNewMail() { item = (EmailListItem *) item->nextSibling(); - } + }*/ @@ -417,2 +445,4 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) + mailboxView->setCurrentTab(0); + } @@ -446,2 +476,4 @@ void EmailClient::allMailArrived(int count) emailHandler->getMailByList(&mailDownloadList); + + mailboxView->setCurrentTab(0); } @@ -511,2 +543,4 @@ void EmailClient::inboxItemSelected() { + killTimer(timerID); + item = (EmailListItem*) inboxView->selectedItem(); @@ -519,2 +553,4 @@ void EmailClient::outboxItemSelected() { + killTimer(timerID); + item = (EmailListItem*) outboxView->selectedItem(); @@ -694,2 +730,3 @@ void EmailClient::saveSettings() { + QString temp; @@ -703,3 +740,3 @@ void EmailClient::saveSettings() QTextStream t(&f); - t << "#Settings for QPE Mailit program\n"; + t << "#Settings for OPIE Mailit program\n"; @@ -813,3 +850,3 @@ void EmailClient::updateAccounts() this, SLOT(editAccount(int)), 0, idCount); - selectAccountMenu->insertItem(accountPtr->accountName, + selectAccountMenu->insertItem(accountPtr->accountName, this, SLOT(selectAccount(int)), 0, idCount); @@ -826,3 +863,4 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) - if (inbox) { + if (inbox) + { mPtr = mailItem->getMail(); @@ -846,3 +884,5 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) inboxView->takeItem(mailItem); - } else { + } + else + { outboxView->takeItem(mailItem); @@ -872 +912,93 @@ void EmailClient::setDownloadedSize(int size) } + +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/unsupported/mailit/emailclient.h b/noncore/unsupported/mailit/emailclient.h index 80457f9..0890dcf 100644 --- a/noncore/unsupported/mailit/emailclient.h +++ b/noncore/unsupported/mailit/emailclient.h @@ -34,2 +34,3 @@ #include <qtooltip.h> +#include <qtoolbutton.h> #include <qimage.h> @@ -42,2 +43,3 @@ #include <opie/otabwidget.h> +#include <qtimer.h> @@ -71,2 +73,5 @@ public: +protected: + void timerEvent(QTimerEvent*); + signals: @@ -76,3 +81,10 @@ signals: 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: @@ -84,2 +96,3 @@ public slots: void mailSent(); + void deleteItem(); void getNewMail(); @@ -90,2 +103,4 @@ public slots: void outboxItemSelected(); + void inboxItemPressed(); + void inboxItemReleased(); void mailArrived(const Email &mail, bool fromDisk); @@ -102,2 +117,6 @@ public slots: void moveMailFront(Email *mailPtr); +/* void reply(); + void replyAll(); + void forward(); + void remove();*/ @@ -109,4 +128,4 @@ private: void saveSettings(); - -private: + Email* getCurrentMail(); + int timerID; Config *mailconf; @@ -130,3 +149,3 @@ private: QLabel *status1Label, *status2Label; - QAction *getMailButton; + QToolButton *getMailButton; QAction *sendMailButton; @@ -134,3 +153,5 @@ private: QAction *cancelButton; - + QAction *deleteButton; + //QToolButton *setAccountButton; + QMenuBar *mb; @@ -139,2 +160,3 @@ private: QPopupMenu *deleteAccountMenu; + QPopupMenu *setAccountMenu; diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index 03f8a28..f6c6d60 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp @@ -202,3 +202,3 @@ 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) { @@ -208,3 +208,9 @@ 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("CC",':', 0, TRUE)) != -1) + { + pos++; + mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); + } + @@ -436,2 +442,9 @@ int EmailHandler::encodeMime(Email *mail) } + + newBody += "\r\nCC: "; + + for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { + newBody += *it + " "; + } + newBody += "\r\nSubject: " + mail->subject + "\r\n"; diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp index 2bf1dcb..ef5fc09 100644 --- a/noncore/unsupported/mailit/mailitwindow.cpp +++ b/noncore/unsupported/mailit/mailitwindow.cpp @@ -49,4 +49,7 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) 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, @@ -85,8 +88,15 @@ void MailItWindow::compose() -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() @@ -133 +143,23 @@ void MailItWindow::setDocument(const QString &_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/unsupported/mailit/mailitwindow.h b/noncore/unsupported/mailit/mailitwindow.h index 667960b..e818d32 100644 --- a/noncore/unsupported/mailit/mailitwindow.h +++ b/noncore/unsupported/mailit/mailitwindow.h @@ -38,5 +38,7 @@ public: +signals: public slots: void compose(); - void composeReply(Email &); + void composeReply(Email &, bool&); + void composeForward(Email &); void showEmailClient(); @@ -47,2 +49,6 @@ public slots: void setDocument(const QString &); + /*void reply(Email&); + void replyAll(Email&); + void forward(Email&); + void remove(Email&);*/ diff --git a/noncore/unsupported/mailit/readmail.cpp b/noncore/unsupported/mailit/readmail.cpp index 7cd3e09..dc98a6f 100644 --- a/noncore/unsupported/mailit/readmail.cpp +++ b/noncore/unsupported/mailit/readmail.cpp @@ -61,3 +61,7 @@ void ReadMail::init() 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 ); @@ -109,2 +113,4 @@ void ReadMail::updateView() replyButton->removeFrom(bar); + forwardButton->removeFrom(mailMenu); + forwardButton->removeFrom(bar); @@ -113,3 +119,6 @@ void ReadMail::updateView() replyButton->addTo(mailMenu); - + forwardButton->addTo(bar); + forwardButton->addTo(mailMenu); + + if (!mail->downloaded) { @@ -147,2 +156,9 @@ void ReadMail::updateView() } + + text +="<br><b>CC: </b>"; + for (QStringList::Iterator it = mail->carbonCopies.begin(); + it != mail->carbonCopies.end(); ++it ) { + text += *it + " "; + } + text += "<br>" + mail->date; @@ -204,2 +220,10 @@ void ReadMail::updateView() } + + text += "\nCC: "; + for (QStringList::Iterator it = mail->carbonCopies.begin(); + it != mail->carbonCopies.end(); ++it ) { + text += *it + " "; + } + + text += "\nDate: " + mail->date + "\n"; @@ -325,3 +349,9 @@ void ReadMail::reply() { - emit replyRequested(*mail); + emit replyRequested(*mail, (bool&)TRUE); } + +void ReadMail::forward() +{ + emit forwardRequested(*mail); +} + diff --git a/noncore/unsupported/mailit/readmail.h b/noncore/unsupported/mailit/readmail.h index d0bb067..0fe0646 100644 --- a/noncore/unsupported/mailit/readmail.h +++ b/noncore/unsupported/mailit/readmail.h @@ -48,3 +48,4 @@ signals: void cancelView(); - void replyRequested(Email &); + void replyRequested(Email &, bool &); + void forwardRequested(Email&); void removeItem(EmailListItem *, bool &); @@ -60,2 +61,3 @@ public slots: void reply(); + void forward(); @@ -83,2 +85,3 @@ private: QAction *replyButton; + QAction *forwardButton; }; diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp index 38a2596..a9dcb02 100644 --- a/noncore/unsupported/mailit/writemail.cpp +++ b/noncore/unsupported/mailit/writemail.cpp @@ -85,5 +85,7 @@ void WriteMail::init() 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))); + @@ -104,2 +106,7 @@ void WriteMail::init() + ccInput = new QLineEdit( widget, "ccInput" ); + ccInput->hide(); + grid->addWidget( ccInput, 0, 1 ); + + addressButton = new QToolButton( widget, "addressButton" ); @@ -141,11 +148,22 @@ void WriteMail::accept() - 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(); @@ -154,2 +172,3 @@ void WriteMail::accept() mail.received = false; + mail.rawMail = "To: "; @@ -162,3 +181,14 @@ void WriteMail::accept() } + 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; @@ -213,3 +243,3 @@ void WriteMail::attatchFile() -void WriteMail::reply(Email replyMail) +void WriteMail::reply(Email replyMail, bool replyAll) { @@ -221,3 +251,7 @@ void WriteMail::reply(Email replyMail) toInput->setText(mail.fromMail); - subjectInput->setText("Re: " + mail.subject); + //replyAll ? ccInput->setText(mail.c) + + addRecipients(replyAll); + + subjectInput->setText(tr("Re: ") + mail.subject); @@ -234,3 +268,22 @@ void WriteMail::reply(Email replyMail) -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) { @@ -241,3 +294,4 @@ bool WriteMail::getRecipients() - temp = toInput->text(); + ccField ? temp = ccInput->text() : temp=toInput->text() ; + while ( (pos = temp.find(';')) != -1) { @@ -247,3 +301,3 @@ bool WriteMail::getRecipients() return false; - mail.recipients.append(str); + ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); addressList->addContact(str, ""); @@ -253,3 +307,3 @@ bool WriteMail::getRecipients() return false; - mail.recipients.append(temp); + ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); addressList->addContact(temp, ""); @@ -258,3 +312,2 @@ bool WriteMail::getRecipients() } - @@ -262,2 +315,8 @@ void WriteMail::addRecipients() { + + addRecipients(false); +} + +void WriteMail::addRecipients(bool ccField) +{ QString recipients = ""; @@ -265,2 +324,3 @@ void WriteMail::addRecipients() mail.recipients.clear(); + QListViewItem *item = addressView->firstChild(); @@ -276,3 +336,4 @@ void WriteMail::addRecipients() } - toInput->setText(recipients); + + ccField ? ccInput->setText(recipients):toInput->setText(recipients); @@ -285,2 +346,16 @@ void WriteMail::addRecipients() +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) diff --git a/noncore/unsupported/mailit/writemail.h b/noncore/unsupported/mailit/writemail.h index dd12063..f193b13 100644 --- a/noncore/unsupported/mailit/writemail.h +++ b/noncore/unsupported/mailit/writemail.h @@ -45,5 +45,6 @@ public: ~WriteMail(); - void reply(Email replyMail); + void reply(Email replyMail, bool replyAll); void setRecipient(const QString &recipient); void setAddressList(AddressList *list); + void forward(Email forwMail); @@ -52,2 +53,3 @@ signals: void cancelMail(); + @@ -60,6 +62,8 @@ public slots: void reject(); + void changeRecipients(int); private: - bool getRecipients(); + bool getRecipients(bool); void init(); + void addRecipients(bool); @@ -85,2 +89,3 @@ private: QLineEdit *toInput; + QLineEdit *ccInput; QToolButton* addressButton; |