summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/emailclient.cpp154
-rw-r--r--noncore/net/mailit/emailclient.h32
-rw-r--r--noncore/net/mailit/emailhandler.cpp17
-rw-r--r--noncore/net/mailit/mailitwindow.cpp40
-rw-r--r--noncore/net/mailit/mailitwindow.h8
-rw-r--r--noncore/net/mailit/readmail.cpp36
-rw-r--r--noncore/net/mailit/readmail.h5
-rw-r--r--noncore/net/mailit/writemail.cpp103
-rw-r--r--noncore/net/mailit/writemail.h9
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp154
-rw-r--r--noncore/unsupported/mailit/emailclient.h32
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp17
-rw-r--r--noncore/unsupported/mailit/mailitwindow.cpp40
-rw-r--r--noncore/unsupported/mailit/mailitwindow.h8
-rw-r--r--noncore/unsupported/mailit/readmail.cpp36
-rw-r--r--noncore/unsupported/mailit/readmail.h5
-rw-r--r--noncore/unsupported/mailit/writemail.cpp103
-rw-r--r--noncore/unsupported/mailit/writemail.h9
18 files changed, 722 insertions, 86 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
index 0d82a9a..ad1e0b4 100644
--- a/noncore/net/mailit/emailclient.cpp
+++ b/noncore/net/mailit/emailclient.cpp
@@ -54,18 +54,22 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
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)) );
mailconf = new Config("mailit");
//In case Synchronize is not defined in settings.txt
@@ -138,20 +142,36 @@ void EmailClient::init()
deleteAccountMenu = new QPopupMenu(mb);
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);
composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) );
@@ -159,16 +179,20 @@ void EmailClient::init()
composeButton->addTo(mail);
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 );
inboxView = new QListView( widget, "inboxView" );
@@ -190,16 +214,18 @@ void EmailClient::init()
outboxView->addColumn( tr( "To" ) );
outboxView->addColumn( tr( "Subject" ) );
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();
}
void EmailClient::cancel()
@@ -227,16 +253,18 @@ 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;
if (accountList.count() == 0) {
QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n");
@@ -291,26 +319,26 @@ void EmailClient::getNewMail() {
getMailButton->setEnabled(FALSE);
cancelButton->setEnabled(TRUE);
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()
{
allAccounts = TRUE;
currentAccount = accountList.first();
@@ -410,16 +438,18 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
item = (EmailListItem *) item->nextSibling();
}
} 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) {
if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
emit newCaption("Mailit - " + currentAccount->accountName);
@@ -439,16 +469,18 @@ 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);
}
}
@@ -504,24 +536,28 @@ void EmailClient::popError(int code)
receiving = FALSE;
getMailButton->setEnabled(TRUE);
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());
}
}
void EmailClient::readMail()
@@ -687,26 +723,27 @@ void EmailClient::readSettings()
}
if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) {
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";
t << "Name: " + accountPtr->name + "\n";
t << "Email: " + accountPtr->emailAddress + "\n";
@@ -806,30 +843,31 @@ void EmailClient::updateAccounts()
editAccountMenu->insertSeparator();
idCount = 0;
for (accountPtr = accountList.first(); accountPtr != 0;
accountPtr = accountList.next()) {
editAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(editAccount(int)), 0, idCount);
- selectAccountMenu->insertItem(accountPtr->accountName,
+ selectAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(selectAccount(int)), 0, idCount);
deleteAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(deleteAccount(int)), 0, idCount);
idCount++;
}
}
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 )
mailDownloadList.remove(mPtr->serverId, mPtr->size);
}
@@ -839,17 +877,19 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
//delete any temporary attatchemnts storing
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)
{
progressBar->reset();
progressBar->setTotalSteps(size);
@@ -865,8 +905,100 @@ void EmailClient::setDownloadedSize(int size)
int total = progressBar->totalSteps();
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
@@ -27,24 +27,26 @@
#include <qtoolbar.h>
#include <qcheckbox.h>
#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"
#include "addresslist.h"
@@ -64,56 +66,73 @@ class EmailClient : public QMainWindow
{
Q_OBJECT
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;
EditAccount *editAccountView;
EmailListItem *item;
@@ -123,25 +142,28 @@ private:
bool sending, receiving, previewingMail, allAccounts;
QString lineShift;
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;
QGridLayout* grid_3;
};
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
@@ -195,23 +195,29 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
mail->fromMail = p.getString(&pos, 'z', TRUE);
if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
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);
}
if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
pos++;
mail->date = p.getString(&pos, 'z', true);
@@ -429,16 +435,23 @@ int EmailHandler::encodeMime(Email *mail)
if (userName.length()>0) //only embrace it if there is a user name
userName += " <" + mailAccount.emailAddress + ">";
//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
@@ -42,18 +42,21 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
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 &)),
this, SLOT(updateCaption(const QString &)) );
viewingMail = FALSE;
@@ -78,22 +81,29 @@ void MailItWindow::compose()
viewingMail = FALSE;
emailClient->hide();
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);
setCaption( tr(currentCaption) );
}
@@ -126,8 +136,30 @@ void MailItWindow::setDocument(const QString &_address)
QString address = _address;
if (address.startsWith("mailto:"))
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
@@ -31,25 +31,31 @@
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;
QString currentCaption;
bool viewingMail;
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
@@ -54,17 +54,21 @@ void ReadMail::init()
menu->insertItem( tr( "&Mail" ), mailMenu);
bar = new QToolBar(this);
//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 );
connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) );
nextButton->addTo(bar);
@@ -102,21 +106,26 @@ void ReadMail::updateView()
QString mailStringSize;
QString text, temp;
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);
double mailSize = (double) mail->size;
if (mailSize < 1024) {
mailStringSize.setNum(mailSize);
@@ -140,16 +149,23 @@ void ReadMail::updateView()
text += "<b>From: </b>" + mail->from + " <i>" +
mail->fromMail + "</i><br>";
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() ) {
text += ePtr->originalName + " ";
}
@@ -197,16 +213,24 @@ void ReadMail::updateView()
emailView->setTextFormat(QTextView::PlainText);
text = "Subject: " + mail->subject + "\n";
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 + " ";
}
text += "\n\n";
} else text += "\n";
@@ -318,10 +342,16 @@ void ReadMail::shiftText()
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
@@ -41,28 +41,30 @@ public:
ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~ReadMail();
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:
QListView *view;
EmailListItem *item;
@@ -76,11 +78,12 @@ private:
QAction *deleteButton;
QMimeSourceFactory *mime;
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
@@ -78,35 +78,42 @@ void WriteMail::init()
newButton->addTo(mailMenu);
connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) );
widget = new QWidget(this, "widget");
grid = new QGridLayout( widget );
recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
recipientsBox->insertItem( tr( "To:" ) );
- recipientsBox->insertItem( tr( "CC:" ) );
+ recipientsBox->insertItem( tr( "CC:" ) );
recipientsBox->setCurrentItem(0);
grid->addWidget( recipientsBox, 0, 0 );
+ connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int)));
+
subjetLabel = new QLabel( widget, "subjetLabel" );
subjetLabel->setText( tr( "Subject:" ) );
grid->addWidget( subjetLabel, 1, 0 );
ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" );
ToolButton13_2->setText( tr( "..." ) );
grid->addWidget( ToolButton13_2, 1, 2 );
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()) );
emailInput = new QMultiLineEdit( widget, "emailInput" );
grid->addMultiCellWidget( emailInput, 2, 2, 0, 2);
@@ -134,38 +141,61 @@ 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();
attatchmentsType = addAtt->returnFileTypes();
@@ -206,88 +236,133 @@ 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()
{
toInput->clear();
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
@@ -38,35 +38,39 @@
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;
QToolBar *bar;
QMenuBar *menu;
@@ -78,14 +82,15 @@ private:
QAction *attatchButton;
QAction *confirmButton;
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
@@ -54,18 +54,22 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl )
connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) );
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)) );
mailconf = new Config("mailit");
//In case Synchronize is not defined in settings.txt
@@ -138,20 +142,36 @@ void EmailClient::init()
deleteAccountMenu = new QPopupMenu(mb);
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);
composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0);
connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) );
@@ -159,16 +179,20 @@ void EmailClient::init()
composeButton->addTo(mail);
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 );
inboxView = new QListView( widget, "inboxView" );
@@ -190,16 +214,18 @@ void EmailClient::init()
outboxView->addColumn( tr( "To" ) );
outboxView->addColumn( tr( "Subject" ) );
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();
}
void EmailClient::cancel()
@@ -227,16 +253,18 @@ 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;
if (accountList.count() == 0) {
QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n");
@@ -291,26 +319,26 @@ void EmailClient::getNewMail() {
getMailButton->setEnabled(FALSE);
cancelButton->setEnabled(TRUE);
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()
{
allAccounts = TRUE;
currentAccount = accountList.first();
@@ -410,16 +438,18 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
item = (EmailListItem *) item->nextSibling();
}
} 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) {
if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
emit newCaption("Mailit - " + currentAccount->accountName);
@@ -439,16 +469,18 @@ 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);
}
}
@@ -504,24 +536,28 @@ void EmailClient::popError(int code)
receiving = FALSE;
getMailButton->setEnabled(TRUE);
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());
}
}
void EmailClient::readMail()
@@ -687,26 +723,27 @@ void EmailClient::readSettings()
}
if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) {
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";
t << "Name: " + accountPtr->name + "\n";
t << "Email: " + accountPtr->emailAddress + "\n";
@@ -806,30 +843,31 @@ void EmailClient::updateAccounts()
editAccountMenu->insertSeparator();
idCount = 0;
for (accountPtr = accountList.first(); accountPtr != 0;
accountPtr = accountList.next()) {
editAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(editAccount(int)), 0, idCount);
- selectAccountMenu->insertItem(accountPtr->accountName,
+ selectAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(selectAccount(int)), 0, idCount);
deleteAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(deleteAccount(int)), 0, idCount);
idCount++;
}
}
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 )
mailDownloadList.remove(mPtr->serverId, mPtr->size);
}
@@ -839,17 +877,19 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
//delete any temporary attatchemnts storing
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)
{
progressBar->reset();
progressBar->setTotalSteps(size);
@@ -865,8 +905,100 @@ void EmailClient::setDownloadedSize(int size)
int total = progressBar->totalSteps();
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
@@ -27,24 +27,26 @@
#include <qtoolbar.h>
#include <qcheckbox.h>
#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"
#include "addresslist.h"
@@ -64,56 +66,73 @@ class EmailClient : public QMainWindow
{
Q_OBJECT
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;
EditAccount *editAccountView;
EmailListItem *item;
@@ -123,25 +142,28 @@ private:
bool sending, receiving, previewingMail, allAccounts;
QString lineShift;
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;
QGridLayout* grid_3;
};
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
@@ -195,23 +195,29 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
mail->fromMail = p.getString(&pos, 'z', TRUE);
if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
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);
}
if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
pos++;
mail->date = p.getString(&pos, 'z', true);
@@ -429,16 +435,23 @@ int EmailHandler::encodeMime(Email *mail)
if (userName.length()>0) //only embrace it if there is a user name
userName += " <" + mailAccount.emailAddress + ">";
//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
@@ -42,18 +42,21 @@ MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl)
connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) );
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 &)),
this, SLOT(updateCaption(const QString &)) );
viewingMail = FALSE;
@@ -78,22 +81,29 @@ void MailItWindow::compose()
viewingMail = FALSE;
emailClient->hide();
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);
setCaption( tr(currentCaption) );
}
@@ -126,8 +136,30 @@ void MailItWindow::setDocument(const QString &_address)
QString address = _address;
if (address.startsWith("mailto:"))
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
@@ -31,25 +31,31 @@
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;
QString currentCaption;
bool viewingMail;
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
@@ -54,17 +54,21 @@ void ReadMail::init()
menu->insertItem( tr( "&Mail" ), mailMenu);
bar = new QToolBar(this);
//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 );
connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) );
nextButton->addTo(bar);
@@ -102,21 +106,26 @@ void ReadMail::updateView()
QString mailStringSize;
QString text, temp;
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);
double mailSize = (double) mail->size;
if (mailSize < 1024) {
mailStringSize.setNum(mailSize);
@@ -140,16 +149,23 @@ void ReadMail::updateView()
text += "<b>From: </b>" + mail->from + " <i>" +
mail->fromMail + "</i><br>";
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() ) {
text += ePtr->originalName + " ";
}
@@ -197,16 +213,24 @@ void ReadMail::updateView()
emailView->setTextFormat(QTextView::PlainText);
text = "Subject: " + mail->subject + "\n";
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 + " ";
}
text += "\n\n";
} else text += "\n";
@@ -318,10 +342,16 @@ void ReadMail::shiftText()
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
@@ -41,28 +41,30 @@ public:
ReadMail( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~ReadMail();
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:
QListView *view;
EmailListItem *item;
@@ -76,11 +78,12 @@ private:
QAction *deleteButton;
QMimeSourceFactory *mime;
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
@@ -78,35 +78,42 @@ void WriteMail::init()
newButton->addTo(mailMenu);
connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) );
widget = new QWidget(this, "widget");
grid = new QGridLayout( widget );
recipientsBox = new QComboBox( FALSE, widget, "toLabel" );
recipientsBox->insertItem( tr( "To:" ) );
- recipientsBox->insertItem( tr( "CC:" ) );
+ recipientsBox->insertItem( tr( "CC:" ) );
recipientsBox->setCurrentItem(0);
grid->addWidget( recipientsBox, 0, 0 );
+ connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int)));
+
subjetLabel = new QLabel( widget, "subjetLabel" );
subjetLabel->setText( tr( "Subject:" ) );
grid->addWidget( subjetLabel, 1, 0 );
ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" );
ToolButton13_2->setText( tr( "..." ) );
grid->addWidget( ToolButton13_2, 1, 2 );
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()) );
emailInput = new QMultiLineEdit( widget, "emailInput" );
grid->addMultiCellWidget( emailInput, 2, 2, 0, 2);
@@ -134,38 +141,61 @@ 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();
attatchmentsType = addAtt->returnFileTypes();
@@ -206,88 +236,133 @@ 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()
{
toInput->clear();
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
@@ -38,35 +38,39 @@
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;
QToolBar *bar;
QMenuBar *menu;
@@ -78,14 +82,15 @@ private:
QAction *attatchButton;
QAction *confirmButton;
QAction *newButton;
QLabel* subjetLabel;
QToolButton* ToolButton13_2;
QComboBox* recipientsBox;
QLineEdit *subjectInput;
QLineEdit *toInput;
+ QLineEdit *ccInput;
QToolButton* addressButton;
QMultiLineEdit* emailInput;
QGridLayout* grid;
};
#endif // WRITEMAIL_H