-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mailit/emailclient.h | 4 | ||||
-rw-r--r-- | noncore/net/mailit/mailit.pro | 2 | ||||
-rw-r--r-- | noncore/net/mailit/readmail.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.h | 4 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailit.pro | 2 | ||||
-rw-r--r-- | noncore/unsupported/mailit/readmail.cpp | 6 |
8 files changed, 20 insertions, 20 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 2e82623..fc4276b 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp @@ -1,578 +1,578 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qapplication.h> #include <qmessagebox.h> #include <qfile.h> #include <qcheckbox.h> #include <qmenubar.h> #include <qaction.h> #include "resource.h" #include "emailclient.h" QCollection::Item AccountList::newItem(QCollection::Item d) { return dupl( (MailAccount *) d); } MailAccount* AccountList::dupl(MailAccount *in) { ac = new MailAccount(*in); return ac; } EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { emailHandler = new EmailHandler(); addressList = new AddressList( getPath(FALSE) + "mail_adr"); sending = FALSE; receiving = FALSE; previewingMail = FALSE; mailIdCount = 1; accountIdCount = 1; allAccounts = FALSE; init(); 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(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 readSettings(); updateAccounts(); lineShift = "\n"; readMail(); lineShift = "\r\n"; } EmailClient::~EmailClient() { //needs to be moved from destructor to closewindow event saveMail(getPath(FALSE) + "inbox.txt", inboxView); //does not currently work. Defining outbox in the same //format as inbox is not a good solution as they have //different properties saveMail(getPath(FALSE) + "outbox.txt", outboxView); saveSettings(); mailconf->write(); delete mailconf; } void EmailClient::init() { statusBar = new QStatusBar(this); statusBar->setSizeGripEnabled(FALSE); status1Label = new QLabel( tr("Idle"), statusBar); status2Label = new QLabel("", statusBar); connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), status2Label, SLOT(setText(const QString &)) ); connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), status2Label, SLOT(setText(const QString &)) ); progressBar = new QProgressBar(statusBar); connect(emailHandler, SIGNAL(mailboxSize(int)), this, SLOT(setTotalSize(int)) ); connect(emailHandler, SIGNAL(currentMailSize(int)), this, SLOT(setMailSize(int)) ); connect(emailHandler, SIGNAL(downloadedSize(int)), this, SLOT(setDownloadedSize(int)) ); statusBar->addWidget(status1Label); statusBar->addWidget(progressBar); statusBar->addWidget(status2Label); setToolBarsMovable(FALSE); bar = new QToolBar(this); bar->setHorizontalStretchable( TRUE ); mb = new QMenuBar( bar ); QPopupMenu *mail = new QPopupMenu(mb); mb->insertItem( tr( "&Mail" ), mail); QPopupMenu *configure = new QPopupMenu(mb); mb->insertItem( tr( "Accounts" ), configure); selectAccountMenu = new QPopupMenu(mb); editAccountMenu = new QPopupMenu(mb); 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); connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); getMailButton->addTo(bar); getMailButton->addTo(mail); sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), 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()) ); composeButton->addTo(bar); composeButton->addTo(mail); - cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("reset"), QString::null, 0, this, 0); + 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->setEnabled(FALSE); - mailboxView = new QTabWidget( this, "mailboxView" ); + 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" ); inboxView->addColumn( tr( "From" ) ); inboxView->addColumn( tr( "Subject" ) ); inboxView->addColumn( tr( "Date" ) ); inboxView->setMinimumSize( QSize( 0, 0 ) ); inboxView->setAllColumnsShowFocus(TRUE); grid_2->addWidget( inboxView, 2, 0 ); - mailboxView->insertTab( widget, tr( "Inbox" ) ); + mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); grid_3 = new QGridLayout( widget_2 ); // grid_3->setSpacing(6); // grid_3->setMargin( 11 ); outboxView = new QListView( widget_2, "outboxView" ); outboxView->addColumn( tr( "To" ) ); outboxView->addColumn( tr( "Subject" ) ); outboxView->setAllColumnsShowFocus(TRUE); grid_3->addWidget( outboxView, 0, 0 ); - mailboxView->insertTab( widget_2, tr( "Outbox" ) ); + mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); setCentralWidget(mailboxView); } void EmailClient::compose() { emit composeRequested(); } void EmailClient::cancel() { emailHandler->cancel(); } AddressList* EmailClient::getAdrListRef() { return addressList; } //this needs to be rewritten to syncronize with outboxView void EmailClient::enqueMail(const Email &mail) { if (accountList.count() > 0) { currentAccount = accountList.first(); qWarning("using account " + currentAccount->name); } 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); } void EmailClient::sendQuedMail() { int count = 0; if (accountList.count() == 0) { QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); return; } //traverse listview, find messages to send if (! sending) { item = (EmailListItem *) outboxView->firstChild(); if (item != NULL) { while (item != NULL) { quedMessages.append(item->getMail()); item = (EmailListItem *) item->nextSibling(); count++; } setMailAccount(); emailHandler->sendMail(&quedMessages); sending = TRUE; sendMailButton->setEnabled(FALSE); cancelButton->setEnabled(TRUE); } else { qWarning("sendQuedMail(): no messages to send"); } } } void EmailClient::setMailAccount() { emailHandler->setAccount(*currentAccount); } void EmailClient::mailSent() { sending = FALSE; sendMailButton->setEnabled(TRUE); quedMessages.clear(); outboxView->clear(); //should be moved to an sentBox } void EmailClient::getNewMail() { if (accountList.count() == 0) { QMessageBox::warning(qApp->activeWindow(),"No account selected", "You must create an account", "OK\n"); return; } setMailAccount(); receiving = TRUE; previewingMail = TRUE; 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(); 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(); getNewMail(); } void EmailClient::mailArrived(const Email &mail, bool fromDisk) { Enclosure *ePtr; Email newMail; int thisMailId; emailHandler->parse(mail.rawMail, lineShift, &newMail); mailconf->setGroup(newMail.id); if (fromDisk) { newMail.downloaded = mailconf->readBoolEntry("downloaded"); newMail.size = mailconf->readNumEntry("size"); newMail.serverId = mailconf->readNumEntry("serverid"); newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); } else { //mail arrived from server newMail.serverId = mail.serverId; newMail.size = mail.size; newMail.downloaded = mail.downloaded; newMail.fromAccountId = currentAccount->id; mailconf->writeEntry("fromaccountid", newMail.fromAccountId); } //add if read or not newMail.read = mailconf->readBoolEntry("mailread"); //check if new mail if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { thisMailId = mailIdCount; mailIdCount++; //set server count, so that if the user aborts, the new //header is not reloaded if (currentAccount->synchronize) currentAccount->lastServerMailCount++; mailconf->writeEntry("internalmailid", thisMailId); mailconf->writeEntry("downloaded", newMail.downloaded); mailconf->writeEntry("size", (int) newMail.size); mailconf->writeEntry("serverid", newMail.serverId); addressList->addContact(newMail.fromMail, newMail.from); } else if (!fromDisk) { //body to header arrived mailconf->writeEntry("downloaded", TRUE); } QString stringMailId; stringMailId.setNum(thisMailId); //se if any attatchments needs to be stored for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { QString stringId; stringId.setNum(ePtr->id); int id = mailconf->readNumEntry("enclosureid_" + stringId); if (id != ePtr->id) { //new entry mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); mailconf->writeEntry("name_" + stringId, ePtr->originalName); mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); mailconf->writeEntry("saved_" + stringId, ePtr->saved); mailconf->writeEntry("installed_" + stringId, FALSE); ePtr->name = stringMailId + "_" + stringId; ePtr->path = getPath(TRUE); if (emailHandler->getEnclosure(ePtr)) { //file saved ePtr->saved = TRUE; mailconf->writeEntry("saved_" + stringId, ePtr->saved); mailconf->writeEntry("filename_" + stringId, ePtr->name); mailconf->writeEntry("path_" + stringId, ePtr->path); } else { ePtr->saved = FALSE; mailconf->writeEntry("saved_" + stringId, ePtr->saved); } } else { ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); if (ePtr->saved) { ePtr->name = mailconf->readEntry("filename_" + stringId); ePtr->path = mailconf->readEntry("path_" + stringId); } } } if (!previewingMail && !fromDisk) { Email *mailPtr; item = (EmailListItem *) inboxView->firstChild(); while (item != NULL) { mailPtr = item->getMail(); if (mailPtr->id == newMail.id) { item->setMail(newMail); emit mailUpdated(item->getMail()); } item = (EmailListItem *) item->nextSibling(); } } else { item = new EmailListItem(inboxView, newMail, TRUE); if (!newMail.downloaded) mailDownloadList.sizeInsert(newMail.serverId, newMail.size); } } 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); getNewMail(); return; } else { allAccounts = FALSE; receiving = FALSE; getMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); status1Label->setText("Idle"); progressBar->reset(); return; } } // all headers downloaded from server, start downloading remaining mails previewingMail = FALSE; status1Label->setText(currentAccount->accountName); progressBar->reset(); emailHandler->getMailByList(&mailDownloadList); } void EmailClient::moveMailFront(Email *mailPtr) { if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); } } void EmailClient::smtpError(int code) { QString temp; if (code == ErrUnknownResponse) temp = "Unknown response from server"; if (code == QSocket::ErrHostNotFound) temp = "host not found"; if (code == QSocket::ErrConnectionRefused) temp = "connection refused"; if (code == QSocket::ErrSocketRead) temp = "socket packet error"; if (code != ErrCancel) { QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); } else { status2Label->setText("Aborted by user"); } sending = FALSE; sendMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); quedMessages.clear(); } void EmailClient::popError(int code) { QString temp; if (code == ErrUnknownResponse) temp = "Unknown response from server"; if (code == ErrLoginFailed) temp = "Login failed\nCheck user name and password"; if (code == QSocket::ErrHostNotFound) temp = "host not found"; if (code == QSocket::ErrConnectionRefused) temp = "connection refused"; if (code == QSocket::ErrSocketRead) temp = "socket packet error"; if (code != ErrCancel) { QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); } else { status2Label->setText("Aborted by user"); } receiving = FALSE; getMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); } void EmailClient::inboxItemSelected() { item = (EmailListItem*) inboxView->selectedItem(); if (item != NULL) { emit viewEmail(inboxView, item->getMail()); } } void EmailClient::outboxItemSelected() { item = (EmailListItem*) outboxView->selectedItem(); if (item != NULL) { emit viewEmail(outboxView, item->getMail()); } } void EmailClient::readMail() { Email mail; int start, stop; QString s, del; QFile f(getPath(FALSE) + "inbox.txt"); // QFileInfo fi(f); qDebug( f.name()); if ( f.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &f ); // use a text stream s = t.read(); f.close(); start = 0; del = "\n.\n"; while ((uint) start < s.length()) { stop = s.find(del, start); if (stop == -1) stop = s.length() - del.length(); mail.rawMail = s.mid(start, stop + del.length() - start ); start = stop + del.length(); mailArrived(mail, TRUE); } } QFile fo(getPath(FALSE) + "outbox.txt"); if ( fo.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &fo ); // use a text stream s = t.read(); fo.close(); start = 0; del = "\n.\n"; while ((uint) start < s.length()) { stop = s.find(del, start); if (stop == -1) stop = s.length() - del.length(); mail.rawMail = s.mid(start, stop + del.length() - start ); start = stop + del.length(); emailHandler->parse(mail.rawMail, lineShift, &mail); mail.sent = false; mail.received = false; enqueMail(mail); } } } void EmailClient::saveMail(QString fileName, QListView *view) { QFile f(fileName); Email *mail; if (! f.open(IO_WriteOnly) ) { diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h index 135bfaa..80457f9 100644 --- a/noncore/net/mailit/emailclient.h +++ b/noncore/net/mailit/emailclient.h @@ -1,149 +1,149 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef EMAILCLIENT_H #define EMAILCLIENT_H #include <qlist.h> #include <qcstring.h> #include <qmainwindow.h> #include <qtoolbar.h> #include <qcheckbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qlistview.h> -#include <qtabwidget.h> #include <qaction.h> #include <qlayout.h> #include <qtooltip.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 "emailhandler.h" #include "emaillistitem.h" #include "textparser.h" #include "editaccount.h" #include "maillist.h" #include "addresslist.h" #include <qpe/config.h> class AccountList : public QList<MailAccount> { public: Item newItem(Item d); private: MailAccount* dupl(MailAccount *in); MailAccount *ac; }; //class EmailClient : public EmailClientBase class EmailClient : public QMainWindow { Q_OBJECT public: EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); ~EmailClient(); AddressList* getAdrListRef(); signals: void composeRequested(); void viewEmail(QListView *, Email *); void mailUpdated(Email *); void newCaption(const QString &); public slots: void compose(); void cancel(); void enqueMail(const Email &mail); void setMailAccount(); void sendQuedMail(); void mailSent(); void getNewMail(); void getAllNewMail(); void smtpError(int code); void popError(int code); void inboxItemSelected(); void outboxItemSelected(); 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); private: void init(); void readMail(); QString getPath(bool enclosurePath); void readSettings(); void saveSettings(); private: Config *mailconf; int newAccountId, idCount, mailIdCount; int accountIdCount; AccountList accountList; AddressList *addressList; EditAccount *editAccountView; EmailListItem *item; EmailHandler *emailHandler; QList<Email> quedMessages; MailList mailDownloadList; bool sending, receiving, previewingMail, allAccounts; QString lineShift; MailAccount account, *currentAccount; QToolBar *bar; QProgressBar *progressBar; QStatusBar *statusBar; QLabel *status1Label, *status2Label; QAction *getMailButton; QAction *sendMailButton; QAction *composeButton; QAction *cancelButton; QMenuBar *mb; QPopupMenu *selectAccountMenu; QPopupMenu *editAccountMenu; QPopupMenu *deleteAccountMenu; - QTabWidget* mailboxView; + OTabWidget* mailboxView; QListView* inboxView; QListView* outboxView; QGridLayout* grid_2; QGridLayout* grid_3; }; #endif // EMAILCLIENT_H diff --git a/noncore/net/mailit/mailit.pro b/noncore/net/mailit/mailit.pro index d51126a..a404884 100644 --- a/noncore/net/mailit/mailit.pro +++ b/noncore/net/mailit/mailit.pro @@ -1,43 +1,43 @@ TEMPLATE = app CONFIG = qt warn_on release HEADERS = emailclient.h \ emailhandler.h \ emaillistitem.h \ mailitwindow.h \ md5.h \ popclient.h \ readmail.h \ smtpclient.h \ writemail.h \ textparser.h \ viewatt.h \ addatt.h \ editaccount.h \ maillist.h \ addresslist.h SOURCES = emailclient.cpp \ emailhandler.cpp \ emaillistitem.cpp \ mailitwindow.cpp \ main.cpp \ md5.c \ popclient.cpp \ readmail.cpp \ smtpclient.cpp \ writemail.cpp \ textparser.cpp \ viewatt.cpp \ addatt.cpp \ editaccount.cpp \ maillist.cpp \ addresslist.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopie # -lssl MOC_DIR=qpeobj OBJECTS_DIR=qpeobj DESTDIR=$(OPIEDIR)/bin include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp index 4954f34..2011ecf 100644 --- a/noncore/net/mailit/readmail.cpp +++ b/noncore/net/mailit/readmail.cpp @@ -1,326 +1,326 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "readmail.h" #include <qimage.h> #include <qmime.h> #include <qaction.h> #include "resource.h" ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl) { plainTxt = FALSE; init(); viewAtt = new ViewAtt(0, "View Attatchments"); } ReadMail::~ReadMail() { delete emailView->mimeSourceFactory(); delete viewAtt; } void ReadMail::init() { setToolBarsMovable(FALSE); bar = new QToolBar(this); bar->setHorizontalStretchable( TRUE ); menu = new QMenuBar( bar ); viewMenu = new QPopupMenu(menu); menu->insertItem( tr( "&View" ), viewMenu); mailMenu = new QPopupMenu(menu); menu->insertItem( tr( "&Mail" ), mailMenu); bar = new QToolBar(this); //reply dependant on viewing inbox - replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "pass" ), + replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), QString::null, 0, this, 0 ); connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); 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); nextButton->addTo(viewMenu); - attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); + attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); connect( attatchmentsButton, SIGNAL( activated() ), this, SLOT( viewAttatchments() ) ); attatchmentsButton->addTo(bar); attatchmentsButton->addTo(viewMenu); - plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0, TRUE); + plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); plainTextButton->addTo(bar); plainTextButton->addTo(viewMenu); deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); deleteButton->addTo(bar); deleteButton->addTo(mailMenu); viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); emailView = new QTextView( this, "emailView" ); setCentralWidget(emailView); mime = new QMimeSourceFactory(); emailView->setMimeSourceFactory(mime); } void ReadMail::updateView() { Enclosure *ePtr; QString mailStringSize; QString text, temp; mail->read = TRUE; //mark as read inbox = mail->received; replyButton->removeFrom(mailMenu); replyButton->removeFrom(bar); if (inbox == TRUE) { replyButton->addTo(bar); replyButton->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); mailStringSize += " Bytes"; } else if (mailSize < 1024*1024) { mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); mailStringSize += " Kb"; } else { mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); mailStringSize += " Mb"; } } } QMimeSourceFactory *mime = emailView->mimeSourceFactory(); if (! plainTxt) { //use RichText, inline pics etc. emailView->setTextFormat(QTextView::RichText); text = "<b><big><center><font color=\"blue\">" + mail->subject +"</font></center></big></b><br>"; 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>" + 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 + " "; } text += "<hr><br>" + mail->body; if (inbox) { for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { text += "<br><hr><b>Attatchment: </b>" + ePtr->originalName + "<hr>"; if (ePtr->contentType == "TEXT") { QFile f(ePtr->path + ePtr->name); if (f.open(IO_ReadOnly) ) { QTextStream t(&f); temp = t.read(); text += temp + "<br>"; f.close(); } else { text += "<b>Could not locate file</b><br>"; } } if (ePtr->contentType == "IMAGE") { // temp.setNum(emailView->width()); //get display width // text += "<img width=" + temp +" src =""" + // ePtr->originalName + """> </img>"; text += "<img src =""" + ePtr->originalName + """> </img>"; mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); } } } } else { if (mail->downloaded || !inbox) { text += "<hr><br>" + mail->body; } else { text += "<hr><br><b> Awaiting download </b><br>"; text += "Size of mail: " + mailStringSize; } } emailView->setText(text); } else { // show plain txt mail 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 += "\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"; if (!inbox) { text += mail->body; } else if (mail->downloaded) { text += mail->bodyPlain; } else { text += "\nAwaiting download\n"; text += "Size of mail: " + mailStringSize; } emailView->setText(text); } if (mail->files.count() == 0) attatchmentsButton->setEnabled(FALSE); else attatchmentsButton->setEnabled(TRUE); setCaption("Examining mail: " + mail->subject); } //update view with current EmailListItem (item) void ReadMail::update(QListView *thisView, Email *mailIn) { view = thisView; item = (EmailListItem *) view->selectedItem(); mail = mailIn; updateView(); updateButtons(); } void ReadMail::mailUpdated(Email *mailIn) { if (mailIn == mail) { updateView(); } else { updateButtons(); } } void ReadMail::close() { emit cancelView(); } //gets next item in listview, exits if there is no next void ReadMail::next() { item = (EmailListItem *) item->nextSibling(); if (item != NULL) { mail = item->getMail(); updateView(); } updateButtons(); } //gets previous item in listview, exits if there is no previous void ReadMail::previous() { item = (EmailListItem *) item->itemAbove(); if (item != NULL) { mail = item->getMail(); updateView(); } updateButtons(); } //deletes item, tries bringing up next or previous, exits if unsucessful void ReadMail::deleteItem() { EmailListItem *temp = item; temp = (EmailListItem *) item->nextSibling(); //trybelow if (temp == NULL) temp = (EmailListItem *) item->itemAbove(); //try above emit removeItem(item, inbox); item = temp; if (item != NULL) { //more items in list mail = item->getMail(); updateView(); updateButtons(); } else close(); //no more items to see } void ReadMail::updateButtons() { EmailListItem *temp; temp = item; if ((EmailListItem *) temp->nextSibling() == NULL) nextButton->setEnabled(FALSE); else nextButton->setEnabled(TRUE); temp = item; if ((EmailListItem *) temp->itemAbove() == NULL) previousButton->setEnabled(FALSE); else previousButton->setEnabled(TRUE); } void ReadMail::shiftText() { plainTxt = ! plainTxt; updateView(); } void ReadMail::viewAttatchments() { viewAtt->update(mail, inbox); viewAtt->showMaximized(); } void ReadMail::reply() { emit replyRequested(*mail); } diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 2e82623..fc4276b 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp @@ -1,578 +1,578 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qapplication.h> #include <qmessagebox.h> #include <qfile.h> #include <qcheckbox.h> #include <qmenubar.h> #include <qaction.h> #include "resource.h" #include "emailclient.h" QCollection::Item AccountList::newItem(QCollection::Item d) { return dupl( (MailAccount *) d); } MailAccount* AccountList::dupl(MailAccount *in) { ac = new MailAccount(*in); return ac; } EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { emailHandler = new EmailHandler(); addressList = new AddressList( getPath(FALSE) + "mail_adr"); sending = FALSE; receiving = FALSE; previewingMail = FALSE; mailIdCount = 1; accountIdCount = 1; allAccounts = FALSE; init(); 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(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 readSettings(); updateAccounts(); lineShift = "\n"; readMail(); lineShift = "\r\n"; } EmailClient::~EmailClient() { //needs to be moved from destructor to closewindow event saveMail(getPath(FALSE) + "inbox.txt", inboxView); //does not currently work. Defining outbox in the same //format as inbox is not a good solution as they have //different properties saveMail(getPath(FALSE) + "outbox.txt", outboxView); saveSettings(); mailconf->write(); delete mailconf; } void EmailClient::init() { statusBar = new QStatusBar(this); statusBar->setSizeGripEnabled(FALSE); status1Label = new QLabel( tr("Idle"), statusBar); status2Label = new QLabel("", statusBar); connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), status2Label, SLOT(setText(const QString &)) ); connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), status2Label, SLOT(setText(const QString &)) ); progressBar = new QProgressBar(statusBar); connect(emailHandler, SIGNAL(mailboxSize(int)), this, SLOT(setTotalSize(int)) ); connect(emailHandler, SIGNAL(currentMailSize(int)), this, SLOT(setMailSize(int)) ); connect(emailHandler, SIGNAL(downloadedSize(int)), this, SLOT(setDownloadedSize(int)) ); statusBar->addWidget(status1Label); statusBar->addWidget(progressBar); statusBar->addWidget(status2Label); setToolBarsMovable(FALSE); bar = new QToolBar(this); bar->setHorizontalStretchable( TRUE ); mb = new QMenuBar( bar ); QPopupMenu *mail = new QPopupMenu(mb); mb->insertItem( tr( "&Mail" ), mail); QPopupMenu *configure = new QPopupMenu(mb); mb->insertItem( tr( "Accounts" ), configure); selectAccountMenu = new QPopupMenu(mb); editAccountMenu = new QPopupMenu(mb); 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); connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); getMailButton->addTo(bar); getMailButton->addTo(mail); sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendmail"), 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()) ); composeButton->addTo(bar); composeButton->addTo(mail); - cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("reset"), QString::null, 0, this, 0); + 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->setEnabled(FALSE); - mailboxView = new QTabWidget( this, "mailboxView" ); + 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" ); inboxView->addColumn( tr( "From" ) ); inboxView->addColumn( tr( "Subject" ) ); inboxView->addColumn( tr( "Date" ) ); inboxView->setMinimumSize( QSize( 0, 0 ) ); inboxView->setAllColumnsShowFocus(TRUE); grid_2->addWidget( inboxView, 2, 0 ); - mailboxView->insertTab( widget, tr( "Inbox" ) ); + mailboxView->addTab( widget, "mailit/inbox", tr( "Inbox" ) ); QWidget* widget_2 = new QWidget( mailboxView, "widget_2" ); grid_3 = new QGridLayout( widget_2 ); // grid_3->setSpacing(6); // grid_3->setMargin( 11 ); outboxView = new QListView( widget_2, "outboxView" ); outboxView->addColumn( tr( "To" ) ); outboxView->addColumn( tr( "Subject" ) ); outboxView->setAllColumnsShowFocus(TRUE); grid_3->addWidget( outboxView, 0, 0 ); - mailboxView->insertTab( widget_2, tr( "Outbox" ) ); + mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); setCentralWidget(mailboxView); } void EmailClient::compose() { emit composeRequested(); } void EmailClient::cancel() { emailHandler->cancel(); } AddressList* EmailClient::getAdrListRef() { return addressList; } //this needs to be rewritten to syncronize with outboxView void EmailClient::enqueMail(const Email &mail) { if (accountList.count() > 0) { currentAccount = accountList.first(); qWarning("using account " + currentAccount->name); } 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); } void EmailClient::sendQuedMail() { int count = 0; if (accountList.count() == 0) { QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); return; } //traverse listview, find messages to send if (! sending) { item = (EmailListItem *) outboxView->firstChild(); if (item != NULL) { while (item != NULL) { quedMessages.append(item->getMail()); item = (EmailListItem *) item->nextSibling(); count++; } setMailAccount(); emailHandler->sendMail(&quedMessages); sending = TRUE; sendMailButton->setEnabled(FALSE); cancelButton->setEnabled(TRUE); } else { qWarning("sendQuedMail(): no messages to send"); } } } void EmailClient::setMailAccount() { emailHandler->setAccount(*currentAccount); } void EmailClient::mailSent() { sending = FALSE; sendMailButton->setEnabled(TRUE); quedMessages.clear(); outboxView->clear(); //should be moved to an sentBox } void EmailClient::getNewMail() { if (accountList.count() == 0) { QMessageBox::warning(qApp->activeWindow(),"No account selected", "You must create an account", "OK\n"); return; } setMailAccount(); receiving = TRUE; previewingMail = TRUE; 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(); 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(); getNewMail(); } void EmailClient::mailArrived(const Email &mail, bool fromDisk) { Enclosure *ePtr; Email newMail; int thisMailId; emailHandler->parse(mail.rawMail, lineShift, &newMail); mailconf->setGroup(newMail.id); if (fromDisk) { newMail.downloaded = mailconf->readBoolEntry("downloaded"); newMail.size = mailconf->readNumEntry("size"); newMail.serverId = mailconf->readNumEntry("serverid"); newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); } else { //mail arrived from server newMail.serverId = mail.serverId; newMail.size = mail.size; newMail.downloaded = mail.downloaded; newMail.fromAccountId = currentAccount->id; mailconf->writeEntry("fromaccountid", newMail.fromAccountId); } //add if read or not newMail.read = mailconf->readBoolEntry("mailread"); //check if new mail if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { thisMailId = mailIdCount; mailIdCount++; //set server count, so that if the user aborts, the new //header is not reloaded if (currentAccount->synchronize) currentAccount->lastServerMailCount++; mailconf->writeEntry("internalmailid", thisMailId); mailconf->writeEntry("downloaded", newMail.downloaded); mailconf->writeEntry("size", (int) newMail.size); mailconf->writeEntry("serverid", newMail.serverId); addressList->addContact(newMail.fromMail, newMail.from); } else if (!fromDisk) { //body to header arrived mailconf->writeEntry("downloaded", TRUE); } QString stringMailId; stringMailId.setNum(thisMailId); //se if any attatchments needs to be stored for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { QString stringId; stringId.setNum(ePtr->id); int id = mailconf->readNumEntry("enclosureid_" + stringId); if (id != ePtr->id) { //new entry mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); mailconf->writeEntry("name_" + stringId, ePtr->originalName); mailconf->writeEntry("contenttype_" + stringId, ePtr->contentType); mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); mailconf->writeEntry("saved_" + stringId, ePtr->saved); mailconf->writeEntry("installed_" + stringId, FALSE); ePtr->name = stringMailId + "_" + stringId; ePtr->path = getPath(TRUE); if (emailHandler->getEnclosure(ePtr)) { //file saved ePtr->saved = TRUE; mailconf->writeEntry("saved_" + stringId, ePtr->saved); mailconf->writeEntry("filename_" + stringId, ePtr->name); mailconf->writeEntry("path_" + stringId, ePtr->path); } else { ePtr->saved = FALSE; mailconf->writeEntry("saved_" + stringId, ePtr->saved); } } else { ePtr->saved = mailconf->readBoolEntry("saved_" + stringId); ePtr->installed = mailconf->readBoolEntry("installed_" + stringId); if (ePtr->saved) { ePtr->name = mailconf->readEntry("filename_" + stringId); ePtr->path = mailconf->readEntry("path_" + stringId); } } } if (!previewingMail && !fromDisk) { Email *mailPtr; item = (EmailListItem *) inboxView->firstChild(); while (item != NULL) { mailPtr = item->getMail(); if (mailPtr->id == newMail.id) { item->setMail(newMail); emit mailUpdated(item->getMail()); } item = (EmailListItem *) item->nextSibling(); } } else { item = new EmailListItem(inboxView, newMail, TRUE); if (!newMail.downloaded) mailDownloadList.sizeInsert(newMail.serverId, newMail.size); } } 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); getNewMail(); return; } else { allAccounts = FALSE; receiving = FALSE; getMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); status1Label->setText("Idle"); progressBar->reset(); return; } } // all headers downloaded from server, start downloading remaining mails previewingMail = FALSE; status1Label->setText(currentAccount->accountName); progressBar->reset(); emailHandler->getMailByList(&mailDownloadList); } void EmailClient::moveMailFront(Email *mailPtr) { if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); } } void EmailClient::smtpError(int code) { QString temp; if (code == ErrUnknownResponse) temp = "Unknown response from server"; if (code == QSocket::ErrHostNotFound) temp = "host not found"; if (code == QSocket::ErrConnectionRefused) temp = "connection refused"; if (code == QSocket::ErrSocketRead) temp = "socket packet error"; if (code != ErrCancel) { QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); } else { status2Label->setText("Aborted by user"); } sending = FALSE; sendMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); quedMessages.clear(); } void EmailClient::popError(int code) { QString temp; if (code == ErrUnknownResponse) temp = "Unknown response from server"; if (code == ErrLoginFailed) temp = "Login failed\nCheck user name and password"; if (code == QSocket::ErrHostNotFound) temp = "host not found"; if (code == QSocket::ErrConnectionRefused) temp = "connection refused"; if (code == QSocket::ErrSocketRead) temp = "socket packet error"; if (code != ErrCancel) { QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); } else { status2Label->setText("Aborted by user"); } receiving = FALSE; getMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); } void EmailClient::inboxItemSelected() { item = (EmailListItem*) inboxView->selectedItem(); if (item != NULL) { emit viewEmail(inboxView, item->getMail()); } } void EmailClient::outboxItemSelected() { item = (EmailListItem*) outboxView->selectedItem(); if (item != NULL) { emit viewEmail(outboxView, item->getMail()); } } void EmailClient::readMail() { Email mail; int start, stop; QString s, del; QFile f(getPath(FALSE) + "inbox.txt"); // QFileInfo fi(f); qDebug( f.name()); if ( f.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &f ); // use a text stream s = t.read(); f.close(); start = 0; del = "\n.\n"; while ((uint) start < s.length()) { stop = s.find(del, start); if (stop == -1) stop = s.length() - del.length(); mail.rawMail = s.mid(start, stop + del.length() - start ); start = stop + del.length(); mailArrived(mail, TRUE); } } QFile fo(getPath(FALSE) + "outbox.txt"); if ( fo.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &fo ); // use a text stream s = t.read(); fo.close(); start = 0; del = "\n.\n"; while ((uint) start < s.length()) { stop = s.find(del, start); if (stop == -1) stop = s.length() - del.length(); mail.rawMail = s.mid(start, stop + del.length() - start ); start = stop + del.length(); emailHandler->parse(mail.rawMail, lineShift, &mail); mail.sent = false; mail.received = false; enqueMail(mail); } } } void EmailClient::saveMail(QString fileName, QListView *view) { QFile f(fileName); Email *mail; if (! f.open(IO_WriteOnly) ) { diff --git a/noncore/unsupported/mailit/emailclient.h b/noncore/unsupported/mailit/emailclient.h index 135bfaa..80457f9 100644 --- a/noncore/unsupported/mailit/emailclient.h +++ b/noncore/unsupported/mailit/emailclient.h @@ -1,149 +1,149 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef EMAILCLIENT_H #define EMAILCLIENT_H #include <qlist.h> #include <qcstring.h> #include <qmainwindow.h> #include <qtoolbar.h> #include <qcheckbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qlistview.h> -#include <qtabwidget.h> #include <qaction.h> #include <qlayout.h> #include <qtooltip.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 "emailhandler.h" #include "emaillistitem.h" #include "textparser.h" #include "editaccount.h" #include "maillist.h" #include "addresslist.h" #include <qpe/config.h> class AccountList : public QList<MailAccount> { public: Item newItem(Item d); private: MailAccount* dupl(MailAccount *in); MailAccount *ac; }; //class EmailClient : public EmailClientBase class EmailClient : public QMainWindow { Q_OBJECT public: EmailClient( QWidget* parent, const char* name, WFlags fl = 0 ); ~EmailClient(); AddressList* getAdrListRef(); signals: void composeRequested(); void viewEmail(QListView *, Email *); void mailUpdated(Email *); void newCaption(const QString &); public slots: void compose(); void cancel(); void enqueMail(const Email &mail); void setMailAccount(); void sendQuedMail(); void mailSent(); void getNewMail(); void getAllNewMail(); void smtpError(int code); void popError(int code); void inboxItemSelected(); void outboxItemSelected(); 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); private: void init(); void readMail(); QString getPath(bool enclosurePath); void readSettings(); void saveSettings(); private: Config *mailconf; int newAccountId, idCount, mailIdCount; int accountIdCount; AccountList accountList; AddressList *addressList; EditAccount *editAccountView; EmailListItem *item; EmailHandler *emailHandler; QList<Email> quedMessages; MailList mailDownloadList; bool sending, receiving, previewingMail, allAccounts; QString lineShift; MailAccount account, *currentAccount; QToolBar *bar; QProgressBar *progressBar; QStatusBar *statusBar; QLabel *status1Label, *status2Label; QAction *getMailButton; QAction *sendMailButton; QAction *composeButton; QAction *cancelButton; QMenuBar *mb; QPopupMenu *selectAccountMenu; QPopupMenu *editAccountMenu; QPopupMenu *deleteAccountMenu; - QTabWidget* mailboxView; + OTabWidget* mailboxView; QListView* inboxView; QListView* outboxView; QGridLayout* grid_2; QGridLayout* grid_3; }; #endif // EMAILCLIENT_H diff --git a/noncore/unsupported/mailit/mailit.pro b/noncore/unsupported/mailit/mailit.pro index d51126a..a404884 100644 --- a/noncore/unsupported/mailit/mailit.pro +++ b/noncore/unsupported/mailit/mailit.pro @@ -1,43 +1,43 @@ TEMPLATE = app CONFIG = qt warn_on release HEADERS = emailclient.h \ emailhandler.h \ emaillistitem.h \ mailitwindow.h \ md5.h \ popclient.h \ readmail.h \ smtpclient.h \ writemail.h \ textparser.h \ viewatt.h \ addatt.h \ editaccount.h \ maillist.h \ addresslist.h SOURCES = emailclient.cpp \ emailhandler.cpp \ emaillistitem.cpp \ mailitwindow.cpp \ main.cpp \ md5.c \ popclient.cpp \ readmail.cpp \ smtpclient.cpp \ writemail.cpp \ textparser.cpp \ viewatt.cpp \ addatt.cpp \ editaccount.cpp \ maillist.cpp \ addresslist.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopie # -lssl MOC_DIR=qpeobj OBJECTS_DIR=qpeobj DESTDIR=$(OPIEDIR)/bin include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/unsupported/mailit/readmail.cpp b/noncore/unsupported/mailit/readmail.cpp index 4954f34..2011ecf 100644 --- a/noncore/unsupported/mailit/readmail.cpp +++ b/noncore/unsupported/mailit/readmail.cpp @@ -1,326 +1,326 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "readmail.h" #include <qimage.h> #include <qmime.h> #include <qaction.h> #include "resource.h" ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl) { plainTxt = FALSE; init(); viewAtt = new ViewAtt(0, "View Attatchments"); } ReadMail::~ReadMail() { delete emailView->mimeSourceFactory(); delete viewAtt; } void ReadMail::init() { setToolBarsMovable(FALSE); bar = new QToolBar(this); bar->setHorizontalStretchable( TRUE ); menu = new QMenuBar( bar ); viewMenu = new QPopupMenu(menu); menu->insertItem( tr( "&View" ), viewMenu); mailMenu = new QPopupMenu(menu); menu->insertItem( tr( "&Mail" ), mailMenu); bar = new QToolBar(this); //reply dependant on viewing inbox - replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "pass" ), + replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), QString::null, 0, this, 0 ); connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); 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); nextButton->addTo(viewMenu); - attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); + attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); connect( attatchmentsButton, SIGNAL( activated() ), this, SLOT( viewAttatchments() ) ); attatchmentsButton->addTo(bar); attatchmentsButton->addTo(viewMenu); - plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0, TRUE); + plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); plainTextButton->addTo(bar); plainTextButton->addTo(viewMenu); deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); deleteButton->addTo(bar); deleteButton->addTo(mailMenu); viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); emailView = new QTextView( this, "emailView" ); setCentralWidget(emailView); mime = new QMimeSourceFactory(); emailView->setMimeSourceFactory(mime); } void ReadMail::updateView() { Enclosure *ePtr; QString mailStringSize; QString text, temp; mail->read = TRUE; //mark as read inbox = mail->received; replyButton->removeFrom(mailMenu); replyButton->removeFrom(bar); if (inbox == TRUE) { replyButton->addTo(bar); replyButton->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); mailStringSize += " Bytes"; } else if (mailSize < 1024*1024) { mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); mailStringSize += " Kb"; } else { mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); mailStringSize += " Mb"; } } } QMimeSourceFactory *mime = emailView->mimeSourceFactory(); if (! plainTxt) { //use RichText, inline pics etc. emailView->setTextFormat(QTextView::RichText); text = "<b><big><center><font color=\"blue\">" + mail->subject +"</font></center></big></b><br>"; 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>" + 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 + " "; } text += "<hr><br>" + mail->body; if (inbox) { for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { text += "<br><hr><b>Attatchment: </b>" + ePtr->originalName + "<hr>"; if (ePtr->contentType == "TEXT") { QFile f(ePtr->path + ePtr->name); if (f.open(IO_ReadOnly) ) { QTextStream t(&f); temp = t.read(); text += temp + "<br>"; f.close(); } else { text += "<b>Could not locate file</b><br>"; } } if (ePtr->contentType == "IMAGE") { // temp.setNum(emailView->width()); //get display width // text += "<img width=" + temp +" src =""" + // ePtr->originalName + """> </img>"; text += "<img src =""" + ePtr->originalName + """> </img>"; mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); } } } } else { if (mail->downloaded || !inbox) { text += "<hr><br>" + mail->body; } else { text += "<hr><br><b> Awaiting download </b><br>"; text += "Size of mail: " + mailStringSize; } } emailView->setText(text); } else { // show plain txt mail 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 += "\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"; if (!inbox) { text += mail->body; } else if (mail->downloaded) { text += mail->bodyPlain; } else { text += "\nAwaiting download\n"; text += "Size of mail: " + mailStringSize; } emailView->setText(text); } if (mail->files.count() == 0) attatchmentsButton->setEnabled(FALSE); else attatchmentsButton->setEnabled(TRUE); setCaption("Examining mail: " + mail->subject); } //update view with current EmailListItem (item) void ReadMail::update(QListView *thisView, Email *mailIn) { view = thisView; item = (EmailListItem *) view->selectedItem(); mail = mailIn; updateView(); updateButtons(); } void ReadMail::mailUpdated(Email *mailIn) { if (mailIn == mail) { updateView(); } else { updateButtons(); } } void ReadMail::close() { emit cancelView(); } //gets next item in listview, exits if there is no next void ReadMail::next() { item = (EmailListItem *) item->nextSibling(); if (item != NULL) { mail = item->getMail(); updateView(); } updateButtons(); } //gets previous item in listview, exits if there is no previous void ReadMail::previous() { item = (EmailListItem *) item->itemAbove(); if (item != NULL) { mail = item->getMail(); updateView(); } updateButtons(); } //deletes item, tries bringing up next or previous, exits if unsucessful void ReadMail::deleteItem() { EmailListItem *temp = item; temp = (EmailListItem *) item->nextSibling(); //trybelow if (temp == NULL) temp = (EmailListItem *) item->itemAbove(); //try above emit removeItem(item, inbox); item = temp; if (item != NULL) { //more items in list mail = item->getMail(); updateView(); updateButtons(); } else close(); //no more items to see } void ReadMail::updateButtons() { EmailListItem *temp; temp = item; if ((EmailListItem *) temp->nextSibling() == NULL) nextButton->setEnabled(FALSE); else nextButton->setEnabled(TRUE); temp = item; if ((EmailListItem *) temp->itemAbove() == NULL) previousButton->setEnabled(FALSE); else previousButton->setEnabled(TRUE); } void ReadMail::shiftText() { plainTxt = ! plainTxt; updateView(); } void ReadMail::viewAttatchments() { viewAtt->update(mail, inbox); viewAtt->showMaximized(); } void ReadMail::reply() { emit replyRequested(*mail); } |