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
@@ -56,14 +56,18 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
connect(emailHandler, SIGNAL(smtpError(int)), this,
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,
SLOT(allMailArrived(int)) );
@@ -140,16 +144,32 @@ void EmailClient::init()
mail->insertItem(tr("Get Mail in"), selectAccountMenu);
configure->insertItem(tr("Edit account"), editAccountMenu);
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);
sendMailButton->addTo(mail);
@@ -161,12 +181,16 @@ void EmailClient::init()
cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0);
connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) );
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 );
// grid_2->setSpacing(6);
// grid_2->setMargin( 11 );
@@ -192,12 +216,14 @@ void EmailClient::init()
outboxView->setAllColumnsShowFocus(TRUE);
grid_3->addWidget( outboxView, 0, 0 );
mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
setCentralWidget(mailboxView);
+
+ mailboxView->setCurrentTab(0);
}
void EmailClient::compose()
{
emit composeRequested();
}
@@ -229,12 +255,14 @@ void EmailClient::enqueMail(const Email &mail)
Email addMail = mail;
addMail.from = currentAccount->name;
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()
{
int count = 0;
@@ -293,22 +321,22 @@ void EmailClient::getNewMail() {
selectAccountMenu->setEnabled(FALSE);
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();
}
void EmailClient::getAllNewMail()
{
@@ -412,12 +440,14 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
} else {
item = new EmailListItem(inboxView, newMail, TRUE);
if (!newMail.downloaded)
mailDownloadList.sizeInsert(newMail.serverId, newMail.size);
}
+ mailboxView->setCurrentTab(0);
+
}
void EmailClient::allMailArrived(int count)
{
// not previewing means all mailtransfer has been done
if (!previewingMail) {
@@ -441,12 +471,14 @@ void EmailClient::allMailArrived(int count)
// all headers downloaded from server, start downloading remaining mails
previewingMail = FALSE;
status1Label->setText(currentAccount->accountName);
progressBar->reset();
emailHandler->getMailByList(&mailDownloadList);
+
+ mailboxView->setCurrentTab(0);
}
void EmailClient::moveMailFront(Email *mailPtr)
{
if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
@@ -506,20 +538,24 @@ void EmailClient::popError(int code)
cancelButton->setEnabled(FALSE);
selectAccountMenu->setEnabled(TRUE);
}
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());
}
}
@@ -689,22 +725,23 @@ void EmailClient::readSettings()
accountIdCount = y;
}
}
void EmailClient::saveSettings()
{
+
QString temp;
QFile f( getPath(FALSE) + "settings.txt");
MailAccount *accountPtr;
if (! f.open(IO_WriteOnly) ) {
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()) {
t << "accountStart;\n";
t << "AccountName: " + accountPtr->accountName + "\n";
@@ -821,13 +858,14 @@ void EmailClient::updateAccounts()
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
if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) {
if ( !mPtr->downloaded )
@@ -841,13 +879,15 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) {
if (ePtr->saved) {
QFile::remove( (ePtr->path + ePtr->name) );
}
}
inboxView->takeItem(mailItem);
- } else {
+ }
+ else
+ {
outboxView->takeItem(mailItem);
}
}
void EmailClient::setMailSize(int size)
{
@@ -867,6 +907,98 @@ void EmailClient::setDownloadedSize(int size)
if (size < total) {
progressBar->setProgress(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
@@ -29,20 +29,22 @@
#include <qlabel.h>
#include <qlineedit.h>
#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"
#include "editaccount.h"
#include "maillist.h"
@@ -66,52 +68,69 @@ class EmailClient : public QMainWindow
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);
void editAccount(int);
void updateAccounts();
void deleteAccount(int);
void deleteMail(EmailListItem *mailItem, bool &inbox);
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;
AddressList *addressList;
@@ -125,21 +144,24 @@ private:
MailAccount account, *currentAccount;
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;
QGridLayout* grid_2;
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
@@ -197,18 +197,24 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
mail->fromMail.truncate(mail->fromMail.length() - 1);
mail->from=mail->fromMail;
}
}
//@@@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);
}
@@ -431,12 +437,19 @@ int EmailHandler::encodeMime(Email *mail)
//add standard headers
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;
mail->rawMail = newBody;
return 0;
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
@@ -44,14 +44,17 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
SLOT(showEmailClient()) );
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 *)) );
connect(emailClient, SIGNAL(newCaption(const QString &)),
@@ -80,18 +83,25 @@ void MailItWindow::compose()
readMail->hide();
views->raiseWidget(writeMail);
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();
readMail->hide();
views->raiseWidget(emailClient);
@@ -128,6 +138,28 @@ void MailItWindow::setDocument(const QString &_address)
address = address.mid(6);
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
@@ -33,21 +33,27 @@ class MailItWindow: public QMainWindow
{
Q_OBJECT
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;
ReadMail *readMail;
QWidgetStack *views;
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
@@ -57,12 +57,16 @@ 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);
nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 );
@@ -104,16 +108,21 @@ void ReadMail::updateView()
mail->read = TRUE; //mark as read
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);
@@ -142,12 +151,19 @@ void ReadMail::updateView()
text +="<b>To: </b>";
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>";
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
@@ -199,12 +215,20 @@ void ReadMail::updateView()
text += "From: " + mail->from + " " + mail->fromMail + "\n";
text += "To: ";
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() ) {
text += ePtr->originalName + " ";
}
@@ -320,8 +344,14 @@ void ReadMail::viewAttatchments()
viewAtt->update(mail, inbox);
viewAtt->showMaximized();
}
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
@@ -43,24 +43,26 @@ public:
void update(QListView *thisView, Email *mailIn);
void updateView();
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:
void close();
void next();
void previous();
void deleteItem();
void shiftText();
void viewAttatchments();
void reply();
+ void forward();
private:
void init();
void updateButtons();
private:
@@ -78,9 +80,10 @@ private:
QAction *plainTextButton;
QAction *nextButton;
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
@@ -83,12 +83,14 @@ void WriteMail::init()
recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
recipientsBox->insertItem( tr( "To:" ) );
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:" ) );
grid->addWidget( subjetLabel, 1, 0 );
@@ -99,12 +101,17 @@ void WriteMail::init()
subjectInput = new QLineEdit( widget, "subjectInput" );
grid->addWidget( subjectInput, 1, 1 );
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 );
connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) );
@@ -136,34 +143,57 @@ void WriteMail::reject()
// need to insert date
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";
attatchedFiles = addAtt->returnAttatchedFiles();
@@ -208,84 +238,129 @@ void WriteMail::getAddress()
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) {
pos = mail.body.find('\n', pos);
if (pos != -1)
mail.body.insert(++pos, ">>");
}
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 == "") {
recipients = item->text(0);
} else {
recipients += "; " + item->text(0);
}
}
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);
}
void WriteMail::newMail()
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
@@ -40,31 +40,35 @@ class WriteMail : public QMainWindow
{
Q_OBJECT
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;
bool showingAddressList;
@@ -80,12 +84,13 @@ private:
QAction *newButton;
QLabel* subjetLabel;
QToolButton* ToolButton13_2;
QComboBox* recipientsBox;
QLineEdit *subjectInput;
QLineEdit *toInput;
+ QLineEdit *ccInput;
QToolButton* addressButton;
QMultiLineEdit* emailInput;
QGridLayout* grid;
};
#endif // WRITEMAIL_H
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
@@ -56,14 +56,18 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
connect(emailHandler, SIGNAL(smtpError(int)), this,
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,
SLOT(allMailArrived(int)) );
@@ -140,16 +144,32 @@ void EmailClient::init()
mail->insertItem(tr("Get Mail in"), selectAccountMenu);
configure->insertItem(tr("Edit account"), editAccountMenu);
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);
sendMailButton->addTo(mail);
@@ -161,12 +181,16 @@ void EmailClient::init()
cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0);
connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) );
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 );
// grid_2->setSpacing(6);
// grid_2->setMargin( 11 );
@@ -192,12 +216,14 @@ void EmailClient::init()
outboxView->setAllColumnsShowFocus(TRUE);
grid_3->addWidget( outboxView, 0, 0 );
mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) );
setCentralWidget(mailboxView);
+
+ mailboxView->setCurrentTab(0);
}
void EmailClient::compose()
{
emit composeRequested();
}
@@ -229,12 +255,14 @@ void EmailClient::enqueMail(const Email &mail)
Email addMail = mail;
addMail.from = currentAccount->name;
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()
{
int count = 0;
@@ -293,22 +321,22 @@ void EmailClient::getNewMail() {
selectAccountMenu->setEnabled(FALSE);
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();
}
void EmailClient::getAllNewMail()
{
@@ -412,12 +440,14 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
} else {
item = new EmailListItem(inboxView, newMail, TRUE);
if (!newMail.downloaded)
mailDownloadList.sizeInsert(newMail.serverId, newMail.size);
}
+ mailboxView->setCurrentTab(0);
+
}
void EmailClient::allMailArrived(int count)
{
// not previewing means all mailtransfer has been done
if (!previewingMail) {
@@ -441,12 +471,14 @@ void EmailClient::allMailArrived(int count)
// all headers downloaded from server, start downloading remaining mails
previewingMail = FALSE;
status1Label->setText(currentAccount->accountName);
progressBar->reset();
emailHandler->getMailByList(&mailDownloadList);
+
+ mailboxView->setCurrentTab(0);
}
void EmailClient::moveMailFront(Email *mailPtr)
{
if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
@@ -506,20 +538,24 @@ void EmailClient::popError(int code)
cancelButton->setEnabled(FALSE);
selectAccountMenu->setEnabled(TRUE);
}
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());
}
}
@@ -689,22 +725,23 @@ void EmailClient::readSettings()
accountIdCount = y;
}
}
void EmailClient::saveSettings()
{
+
QString temp;
QFile f( getPath(FALSE) + "settings.txt");
MailAccount *accountPtr;
if (! f.open(IO_WriteOnly) ) {
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()) {
t << "accountStart;\n";
t << "AccountName: " + accountPtr->accountName + "\n";
@@ -821,13 +858,14 @@ void EmailClient::updateAccounts()
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
if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) {
if ( !mPtr->downloaded )
@@ -841,13 +879,15 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) {
if (ePtr->saved) {
QFile::remove( (ePtr->path + ePtr->name) );
}
}
inboxView->takeItem(mailItem);
- } else {
+ }
+ else
+ {
outboxView->takeItem(mailItem);
}
}
void EmailClient::setMailSize(int size)
{
@@ -867,6 +907,98 @@ void EmailClient::setDownloadedSize(int size)
if (size < total) {
progressBar->setProgress(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/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
@@ -29,20 +29,22 @@
#include <qlabel.h>
#include <qlineedit.h>
#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"
#include "editaccount.h"
#include "maillist.h"
@@ -66,52 +68,69 @@ class EmailClient : public QMainWindow
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);
void editAccount(int);
void updateAccounts();
void deleteAccount(int);
void deleteMail(EmailListItem *mailItem, bool &inbox);
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;
AddressList *addressList;
@@ -125,21 +144,24 @@ private:
MailAccount account, *currentAccount;
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;
QGridLayout* grid_2;
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
@@ -197,18 +197,24 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
mail->fromMail.truncate(mail->fromMail.length() - 1);
mail->from=mail->fromMail;
}
}
//@@@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);
}
@@ -431,12 +437,19 @@ int EmailHandler::encodeMime(Email *mail)
//add standard headers
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;
mail->rawMail = newBody;
return 0;
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
@@ -44,14 +44,17 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this,
SLOT(showEmailClient()) );
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 *)) );
connect(emailClient, SIGNAL(newCaption(const QString &)),
@@ -80,18 +83,25 @@ void MailItWindow::compose()
readMail->hide();
views->raiseWidget(writeMail);
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();
readMail->hide();
views->raiseWidget(emailClient);
@@ -128,6 +138,28 @@ void MailItWindow::setDocument(const QString &_address)
address = address.mid(6);
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/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
@@ -33,21 +33,27 @@ class MailItWindow: public QMainWindow
{
Q_OBJECT
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;
ReadMail *readMail;
QWidgetStack *views;
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
@@ -57,12 +57,16 @@ 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);
nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 );
@@ -104,16 +108,21 @@ void ReadMail::updateView()
mail->read = TRUE; //mark as read
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);
@@ -142,12 +151,19 @@ void ReadMail::updateView()
text +="<b>To: </b>";
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>";
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
@@ -199,12 +215,20 @@ void ReadMail::updateView()
text += "From: " + mail->from + " " + mail->fromMail + "\n";
text += "To: ";
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() ) {
text += ePtr->originalName + " ";
}
@@ -320,8 +344,14 @@ void ReadMail::viewAttatchments()
viewAtt->update(mail, inbox);
viewAtt->showMaximized();
}
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
@@ -43,24 +43,26 @@ public:
void update(QListView *thisView, Email *mailIn);
void updateView();
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:
void close();
void next();
void previous();
void deleteItem();
void shiftText();
void viewAttatchments();
void reply();
+ void forward();
private:
void init();
void updateButtons();
private:
@@ -78,9 +80,10 @@ private:
QAction *plainTextButton;
QAction *nextButton;
QTextView *emailView;
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
@@ -83,12 +83,14 @@ void WriteMail::init()
recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
recipientsBox->insertItem( tr( "To:" ) );
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:" ) );
grid->addWidget( subjetLabel, 1, 0 );
@@ -99,12 +101,17 @@ void WriteMail::init()
subjectInput = new QLineEdit( widget, "subjectInput" );
grid->addWidget( subjectInput, 1, 1 );
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 );
connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) );
@@ -136,34 +143,57 @@ void WriteMail::reject()
// need to insert date
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";
attatchedFiles = addAtt->returnAttatchedFiles();
@@ -208,84 +238,129 @@ void WriteMail::getAddress()
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) {
pos = mail.body.find('\n', pos);
if (pos != -1)
mail.body.insert(++pos, ">>");
}
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 == "") {
recipients = item->text(0);
} else {
recipients += "; " + item->text(0);
}
}
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);
}
void WriteMail::newMail()
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
@@ -40,31 +40,35 @@ class WriteMail : public QMainWindow
{
Q_OBJECT
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;
bool showingAddressList;
@@ -80,12 +84,13 @@ private:
QAction *newButton;
QLabel* subjetLabel;
QToolButton* ToolButton13_2;
QComboBox* recipientsBox;
QLineEdit *subjectInput;
QLineEdit *toInput;
+ QLineEdit *ccInput;
QToolButton* addressButton;
QMultiLineEdit* emailInput;
QGridLayout* grid;
};
#endif // WRITEMAIL_H