summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mailit/emailclient.cpp152
-rw-r--r--noncore/net/mailit/emailclient.h28
-rw-r--r--noncore/net/mailit/emailhandler.cpp15
-rw-r--r--noncore/net/mailit/mailitwindow.cpp40
-rw-r--r--noncore/net/mailit/mailitwindow.h8
-rw-r--r--noncore/net/mailit/readmail.cpp32
-rw-r--r--noncore/net/mailit/readmail.h5
-rw-r--r--noncore/net/mailit/writemail.cpp101
-rw-r--r--noncore/net/mailit/writemail.h9
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp152
-rw-r--r--noncore/unsupported/mailit/emailclient.h28
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp15
-rw-r--r--noncore/unsupported/mailit/mailitwindow.cpp40
-rw-r--r--noncore/unsupported/mailit/mailitwindow.h8
-rw-r--r--noncore/unsupported/mailit/readmail.cpp32
-rw-r--r--noncore/unsupported/mailit/readmail.h5
-rw-r--r--noncore/unsupported/mailit/writemail.cpp101
-rw-r--r--noncore/unsupported/mailit/writemail.h9
18 files changed, 708 insertions, 72 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
@@ -59,8 +59,12 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
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)) );
@@ -143,10 +147,26 @@ void EmailClient::init()
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()) );
@@ -164,6 +184,10 @@ void EmailClient::init()
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" );
@@ -195,6 +219,8 @@ void EmailClient::init()
mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
setCentralWidget(mailboxView);
+
+ mailboxView->setCurrentTab(0);
}
void EmailClient::compose()
@@ -232,6 +258,8 @@ void EmailClient::enqueMail(const Email &mail)
addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n");
item = new EmailListItem(outboxView, addMail, false);
+ mailboxView->setCurrentTab(1);
+
}
void EmailClient::sendQuedMail()
@@ -296,7 +324,7 @@ void EmailClient::getNewMail() {
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) {
@@ -305,7 +333,7 @@ void EmailClient::getNewMail() {
mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size);
}
item = (EmailListItem *) item->nextSibling();
- }
+ }*/
emailHandler->getMailHeaders();
}
@@ -415,6 +443,8 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
mailDownloadList.sizeInsert(newMail.serverId, newMail.size);
}
+ mailboxView->setCurrentTab(0);
+
}
void EmailClient::allMailArrived(int count)
@@ -444,6 +474,8 @@ void EmailClient::allMailArrived(int count)
progressBar->reset();
emailHandler->getMailByList(&mailDownloadList);
+
+ mailboxView->setCurrentTab(0);
}
void EmailClient::moveMailFront(Email *mailPtr)
@@ -509,6 +541,8 @@ void EmailClient::popError(int code)
void EmailClient::inboxItemSelected()
{
+ killTimer(timerID);
+
item = (EmailListItem*) inboxView->selectedItem();
if (item != NULL) {
emit viewEmail(inboxView, item->getMail());
@@ -517,6 +551,8 @@ void EmailClient::inboxItemSelected()
void EmailClient::outboxItemSelected()
{
+ killTimer(timerID);
+
item = (EmailListItem*) outboxView->selectedItem();
if (item != NULL) {
emit viewEmail(outboxView, item->getMail());
@@ -692,6 +728,7 @@ void EmailClient::readSettings()
void EmailClient::saveSettings()
{
+
QString temp;
QFile f( getPath(FALSE) + "settings.txt");
MailAccount *accountPtr;
@@ -701,7 +738,7 @@ void EmailClient::saveSettings()
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()) {
@@ -824,7 +861,8 @@ 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
@@ -844,7 +882,9 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
}
}
inboxView->takeItem(mailItem);
- } else {
+ }
+ else
+ {
outboxView->takeItem(mailItem);
}
}
@@ -870,3 +910,95 @@ void EmailClient::setDownloadedSize(int size)
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
@@ -32,6 +32,7 @@
#include <qaction.h>
#include <qlayout.h>
#include <qtooltip.h>
+#include <qtoolbutton.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qstringlist.h>
@@ -40,6 +41,7 @@
#include <qdir.h>
#include <stdlib.h>
#include <opie/otabwidget.h>
+#include <qtimer.h>
#include "emailhandler.h"
#include "emaillistitem.h"
@@ -69,11 +71,21 @@ public:
~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();
@@ -82,12 +94,15 @@ public slots:
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);
@@ -100,6 +115,10 @@ public slots:
void setMailSize(int);
void setDownloadedSize(int);
void moveMailFront(Email *mailPtr);
+/* void reply();
+ void replyAll();
+ void forward();
+ void remove();*/
private:
void init();
@@ -107,8 +126,8 @@ private:
QString getPath(bool enclosurePath);
void readSettings();
void saveSettings();
-
-private:
+ Email* getCurrentMail();
+ int timerID;
Config *mailconf;
int newAccountId, idCount, mailIdCount;
int accountIdCount;
@@ -128,15 +147,18 @@ private:
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;
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
@@ -200,12 +200,18 @@ 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) {
@@ -434,6 +440,13 @@ int EmailHandler::encodeMime(Email *mail)
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
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
@@ -47,8 +47,11 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
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,
@@ -83,12 +86,19 @@ void MailItWindow::compose()
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;
@@ -131,3 +141,25 @@ void MailItWindow::setDocument(const QString &_address)
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
@@ -36,15 +36,21 @@ 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;
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
@@ -60,6 +60,10 @@ void ReadMail::init()
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);
@@ -107,10 +111,15 @@ void ReadMail::updateView()
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
@@ -145,6 +154,13 @@ void ReadMail::updateView()
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) {
@@ -202,6 +218,14 @@ void ReadMail::updateView()
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: ";
@@ -323,5 +347,11 @@ 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
@@ -46,7 +46,8 @@ public:
signals:
void cancelView();
- void replyRequested(Email &);
+ void replyRequested(Email &, bool &);
+ void forwardRequested(Email&);
void removeItem(EmailListItem *, bool &);
void viewingMail(Email *);
@@ -58,6 +59,7 @@ public slots:
void shiftText();
void viewAttatchments();
void reply();
+ void forward();
private:
void init();
@@ -81,6 +83,7 @@ private:
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
@@ -86,6 +86,8 @@ void WriteMail::init()
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:" ) );
@@ -102,6 +104,11 @@ 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);
@@ -139,19 +146,31 @@ 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();
@@ -160,7 +179,18 @@ void WriteMail::accept()
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;
@@ -211,7 +241,7 @@ void WriteMail::attatchFile()
addAtt->showMaximized();
}
-void WriteMail::reply(Email replyMail)
+void WriteMail::reply(Email replyMail, bool replyAll)
{
int pos;
@@ -219,7 +249,11 @@ void WriteMail::reply(Email 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, ">>");
@@ -232,37 +266,63 @@ 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() ) {
@@ -274,7 +334,8 @@ void WriteMail::addRecipients()
}
item = item->nextSibling();
}
- toInput->setText(recipients);
+
+ ccField ? ccInput->setText(recipients):toInput->setText(recipients);
addressView->hide();
okButton->hide();
@@ -283,6 +344,20 @@ void WriteMail::addRecipients()
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
@@ -43,14 +43,16 @@ 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();
@@ -58,10 +60,12 @@ public slots:
void newMail();
void accept();
void reject();
+ void changeRecipients(int);
private:
- bool getRecipients();
+ bool getRecipients(bool);
void init();
+ void addRecipients(bool);
Email mail;
AddAtt *addAtt;
@@ -83,6 +87,7 @@ private:
QComboBox* recipientsBox;
QLineEdit *subjectInput;
QLineEdit *toInput;
+ QLineEdit *ccInput;
QToolButton* addressButton;
QMultiLineEdit* emailInput;
QGridLayout* grid;
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
@@ -59,8 +59,12 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
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)) );
@@ -143,10 +147,26 @@ void EmailClient::init()
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()) );
@@ -164,6 +184,10 @@ void EmailClient::init()
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" );
@@ -195,6 +219,8 @@ void EmailClient::init()
mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
setCentralWidget(mailboxView);
+
+ mailboxView->setCurrentTab(0);
}
void EmailClient::compose()
@@ -232,6 +258,8 @@ void EmailClient::enqueMail(const Email &mail)
addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n");
item = new EmailListItem(outboxView, addMail, false);
+ mailboxView->setCurrentTab(1);
+
}
void EmailClient::sendQuedMail()
@@ -296,7 +324,7 @@ void EmailClient::getNewMail() {
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) {
@@ -305,7 +333,7 @@ void EmailClient::getNewMail() {
mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size);
}
item = (EmailListItem *) item->nextSibling();
- }
+ }*/
emailHandler->getMailHeaders();
}
@@ -415,6 +443,8 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
mailDownloadList.sizeInsert(newMail.serverId, newMail.size);
}
+ mailboxView->setCurrentTab(0);
+
}
void EmailClient::allMailArrived(int count)
@@ -444,6 +474,8 @@ void EmailClient::allMailArrived(int count)
progressBar->reset();
emailHandler->getMailByList(&mailDownloadList);
+
+ mailboxView->setCurrentTab(0);
}
void EmailClient::moveMailFront(Email *mailPtr)
@@ -509,6 +541,8 @@ void EmailClient::popError(int code)
void EmailClient::inboxItemSelected()
{
+ killTimer(timerID);
+
item = (EmailListItem*) inboxView->selectedItem();
if (item != NULL) {
emit viewEmail(inboxView, item->getMail());
@@ -517,6 +551,8 @@ void EmailClient::inboxItemSelected()
void EmailClient::outboxItemSelected()
{
+ killTimer(timerID);
+
item = (EmailListItem*) outboxView->selectedItem();
if (item != NULL) {
emit viewEmail(outboxView, item->getMail());
@@ -692,6 +728,7 @@ void EmailClient::readSettings()
void EmailClient::saveSettings()
{
+
QString temp;
QFile f( getPath(FALSE) + "settings.txt");
MailAccount *accountPtr;
@@ -701,7 +738,7 @@ void EmailClient::saveSettings()
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()) {
@@ -824,7 +861,8 @@ 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
@@ -844,7 +882,9 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
}
}
inboxView->takeItem(mailItem);
- } else {
+ }
+ else
+ {
outboxView->takeItem(mailItem);
}
}
@@ -870,3 +910,95 @@ void EmailClient::setDownloadedSize(int size)
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/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
@@ -32,6 +32,7 @@
#include <qaction.h>
#include <qlayout.h>
#include <qtooltip.h>
+#include <qtoolbutton.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qstringlist.h>
@@ -40,6 +41,7 @@
#include <qdir.h>
#include <stdlib.h>
#include <opie/otabwidget.h>
+#include <qtimer.h>
#include "emailhandler.h"
#include "emaillistitem.h"
@@ -69,11 +71,21 @@ public:
~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();
@@ -82,12 +94,15 @@ public slots:
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);
@@ -100,6 +115,10 @@ public slots:
void setMailSize(int);
void setDownloadedSize(int);
void moveMailFront(Email *mailPtr);
+/* void reply();
+ void replyAll();
+ void forward();
+ void remove();*/
private:
void init();
@@ -107,8 +126,8 @@ private:
QString getPath(bool enclosurePath);
void readSettings();
void saveSettings();
-
-private:
+ Email* getCurrentMail();
+ int timerID;
Config *mailconf;
int newAccountId, idCount, mailIdCount;
int accountIdCount;
@@ -128,15 +147,18 @@ private:
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;
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
@@ -200,12 +200,18 @@ 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) {
@@ -434,6 +440,13 @@ int EmailHandler::encodeMime(Email *mail)
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
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
@@ -47,8 +47,11 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
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,
@@ -83,12 +86,19 @@ void MailItWindow::compose()
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;
@@ -131,3 +141,25 @@ void MailItWindow::setDocument(const QString &_address)
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/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
@@ -36,15 +36,21 @@ 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;
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
@@ -60,6 +60,10 @@ void ReadMail::init()
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);
@@ -107,10 +111,15 @@ void ReadMail::updateView()
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
@@ -145,6 +154,13 @@ void ReadMail::updateView()
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) {
@@ -202,6 +218,14 @@ void ReadMail::updateView()
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: ";
@@ -323,5 +347,11 @@ void ReadMail::viewAttatchments()
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
@@ -46,7 +46,8 @@ public:
signals:
void cancelView();
- void replyRequested(Email &);
+ void replyRequested(Email &, bool &);
+ void forwardRequested(Email&);
void removeItem(EmailListItem *, bool &);
void viewingMail(Email *);
@@ -58,6 +59,7 @@ public slots:
void shiftText();
void viewAttatchments();
void reply();
+ void forward();
private:
void init();
@@ -81,6 +83,7 @@ private:
QAction *attatchmentsButton;
QAction *previousButton;
QAction *replyButton;
+ QAction *forwardButton;
};
#endif // READMAIL_H
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
@@ -86,6 +86,8 @@ void WriteMail::init()
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:" ) );
@@ -102,6 +104,11 @@ 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);
@@ -139,19 +146,31 @@ 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();
@@ -160,7 +179,18 @@ void WriteMail::accept()
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;
@@ -211,7 +241,7 @@ void WriteMail::attatchFile()
addAtt->showMaximized();
}
-void WriteMail::reply(Email replyMail)
+void WriteMail::reply(Email replyMail, bool replyAll)
{
int pos;
@@ -219,7 +249,11 @@ void WriteMail::reply(Email 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, ">>");
@@ -232,37 +266,63 @@ 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() ) {
@@ -274,7 +334,8 @@ void WriteMail::addRecipients()
}
item = item->nextSibling();
}
- toInput->setText(recipients);
+
+ ccField ? ccInput->setText(recipients):toInput->setText(recipients);
addressView->hide();
okButton->hide();
@@ -283,6 +344,20 @@ void WriteMail::addRecipients()
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/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
@@ -43,14 +43,16 @@ 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();
@@ -58,10 +60,12 @@ public slots:
void newMail();
void accept();
void reject();
+ void changeRecipients(int);
private:
- bool getRecipients();
+ bool getRecipients(bool);
void init();
+ void addRecipients(bool);
Email mail;
AddAtt *addAtt;
@@ -83,6 +87,7 @@ private:
QComboBox* recipientsBox;
QLineEdit *subjectInput;
QLineEdit *toInput;
+ QLineEdit *ccInput;
QToolButton* addressButton;
QMultiLineEdit* emailInput;
QGridLayout* grid;