author | groucho <groucho> | 2003-04-13 10:29:05 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-04-13 10:29:05 (UTC) |
commit | 8cc217bed9c122a7c7448e2cd59bfde330dfcfad (patch) (side-by-side diff) | |
tree | f802c03bbddf54ecc541ce23bdc43da0fc8b390b | |
parent | 64d6b3e723b9b2fc3b1f3eea6da6344c5f26ce1e (diff) | |
download | opie-8cc217bed9c122a7c7448e2cd59bfde330dfcfad.zip opie-8cc217bed9c122a7c7448e2cd59bfde330dfcfad.tar.gz opie-8cc217bed9c122a7c7448e2cd59bfde330dfcfad.tar.bz2 |
- Uses mime types for attachment reading
- Addresses are read from ocontactacess
-rw-r--r-- | noncore/net/mailit/addatt.cpp | 34 | ||||
-rw-r--r-- | noncore/net/mailit/addatt.h | 8 | ||||
-rw-r--r-- | noncore/net/mailit/addresslist.cpp | 20 | ||||
-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mailit/mailitwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mailit/viewatt.cpp | 15 | ||||
-rw-r--r-- | noncore/net/mailit/writemail.cpp | 5 | ||||
-rw-r--r-- | noncore/unsupported/mailit/addatt.cpp | 34 | ||||
-rw-r--r-- | noncore/unsupported/mailit/addatt.h | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/addresslist.cpp | 20 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailitwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/unsupported/mailit/viewatt.cpp | 15 | ||||
-rw-r--r-- | noncore/unsupported/mailit/writemail.cpp | 5 |
14 files changed, 110 insertions, 66 deletions
diff --git a/noncore/net/mailit/addatt.cpp b/noncore/net/mailit/addatt.cpp index f279f52..c8be865 100644 --- a/noncore/net/mailit/addatt.cpp +++ b/noncore/net/mailit/addatt.cpp @@ -1,230 +1,224 @@ /********************************************************************** ** 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 <qlayout.h> +#include <qhbox.h> #include <qdir.h> #include <qstringlist.h> #include "resource.h" #include "addatt.h" FileItem::FileItem(QListView *parent, DocLnk* dl) : QListViewItem(parent) { /*file = fileInfo; type = fileType;*/ doclnk=dl; setText(0, doclnk->name()); /* if (fileType == "Picture") { setPixmap(0, Resource::loadPixmap("pixmap")); } else if (fileType == "Document") { setPixmap(0, Resource::loadPixmap("txt")); } else if (fileType == "Sound") { setPixmap(0, Resource::loadPixmap("play")); } else if (fileType == "Movie") { setPixmap(0, Resource::loadPixmap("MPEGPlayer")); } else if (fileType == "File") { setPixmap(0, Resource::loadPixmap("exec")); }*/ } FileItem::~FileItem() { if (doclnk!=NULL) delete doclnk; doclnk=NULL; } AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) : QDialog(parent, name, f) { setCaption("Adding attatchments"); - QGridLayout *top = new QGridLayout(this, 3,1 ); + QGridLayout *top = new QGridLayout(this, 1,1 ); - + QHBox *buttons=new QHBox(this); /*fileCategoryButton = new QPushButton(this);*/ - attatchButton = new QPushButton("Attatch ->", this); - removeButton = new QPushButton("Remove", this); + attatchButton = new QPushButton("Attatch ->", buttons); + removeButton = new QPushButton("Remove", buttons); /*fileCategories = new QPopupMenu(fileCategoryButton); fileCategoryButton->setPopup(fileCategories); fileCategories->insertItem("Document"); fileCategories->insertItem("Picture"); fileCategories->insertItem("Sound"); fileCategories->insertItem("Movie"); fileCategories->insertItem("File"); fileCategoryButton->setText("Document"); top->addWidget(fileCategoryButton, 0, 0);*/ - //ofs=new OFileSelector(this,2,0,"/root/Documents"); - - - top->addWidget(attatchButton,1,0); - top->addWidget(removeButton,2,0); - /*connect(fileCategories, SIGNAL(activated(int)), this, - SLOT(fileCategorySelected(int)) );*/ + top->addWidget(buttons,1,0); + //buttons->addWidget(attatchButton,0,0); + //buttons->addWidget(removeButton,0,1); + + //connect(fileCategories, SIGNAL(activated(int)), this, + // SLOT(fileCategorySelected(int)) );*/ connect(attatchButton, SIGNAL(clicked()), this, SLOT(addAttatchment()) ); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeAttatchment()) ); /*listView = new QListView(this, "AttView"); listView->addColumn("Documents");* connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(addAttatchment()) );*/ attView = new QListView(this, "Selected"); attView->addColumn(tr("Attached")); attView->addColumn(tr("File type")); connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(removeAttatchment()) ); //top->addWidget(ofs, 0,0); top->addWidget(attView, 0,0); clear(); } void AddAtt::clear() { attView->clear(); //getFiles(); modified = FALSE; } /*void AddAtt::fileCategorySelected(int id) { fileCategoryButton->setText(fileCategories->text(id)); getFiles(); }*/ void AddAtt::addAttatchment() { - QDialog qd(this,tr("Select attachment"),true); - - QGridLayout top(&qd,1,1); - - OFileSelector ofs(&qd,1,0,"/root/Documents"); - - top.addWidget(&ofs,0,0); + OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); - qd.showMaximized(); + ofs.showMaximized(); - if (qd.exec()==QDialog::Accepted) + if (ofs.exec()==QDialog::Accepted) { DocLnk* dl=new DocLnk(ofs.selectedDocument()); FileItem* fi=new FileItem(attView,dl); fi->setPixmap(0,dl->pixmap()); fi->setText(1,dl->type()); attView->insertItem(fi); modified = TRUE; } } void AddAtt::removeAttatchment() { if (attView->selectedItem() != NULL) { attView->takeItem(attView->selectedItem()); } modified = TRUE; } void AddAtt::reject() { if (modified) { attView->clear(); modified = FALSE; } } void AddAtt::accept() { modified = FALSE; hide(); } void AddAtt::getFiles() { QString path, selected; /*listView->clear(); selected = fileCategoryButton->text(); if (selected == "Picture") { path = "../pics/"; } else if (selected == "Document") { path = "" ; //sub-dirs not decided } else if (selected == "Sound") { path = "../sounds/"; //sub-dirs not decided } else if (selected == "Movie") { path = ""; //sub-dirs not decided } else if (selected == "File") { path = ""; //sub-dirs not decided } dir = new QDir(path); dir->setFilter(QDir::Files); const QFileInfoList *dirInfoList = dir->entryInfoList(); QFileInfoListIterator it(*dirInfoList); // create list iterator while ( (fi=it.current()) ) { // for each file... item = new FileItem(lis+ütView, *fi, selected); ++it; // goto next list element }*/ } QStringList AddAtt::returnAttatchedFiles() { QFileInfo info; QStringList list; item = (FileItem *) attView->firstChild(); while (item != NULL) { DocLnk* dl=item->getDocLnk(); list+=dl->file(); /*info = item->getFileInfo(); list += info.filePath();*/ item = (FileItem *) item->nextSibling(); } return list; } QStringList AddAtt::returnFileTypes() { QStringList list; item = (FileItem *) attView->firstChild(); while (item != NULL) { list += item->getDocLnk()->type(); item = (FileItem *) item->nextSibling(); } return list; } diff --git a/noncore/net/mailit/addatt.h b/noncore/net/mailit/addatt.h index 73062e2..fcf3279 100644 --- a/noncore/net/mailit/addatt.h +++ b/noncore/net/mailit/addatt.h @@ -1,76 +1,76 @@ /********************************************************************** ** 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 ADDATT_H #define ADDATT_H #include <qdialog.h> #include <qlistview.h> #include <qpushbutton.h> #include <qpopupmenu.h> #include <qstring.h> #include <qfileinfo.h> #include <qstringlist.h> -#include <opie/ofileselector.h> +#include <opie/ofiledialog.h> #include <qpe/applnk.h> class FileItem : public QListViewItem { public: //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); FileItem(QListView*, DocLnk*); ~FileItem(); DocLnk* getDocLnk() {return doclnk;} private: DocLnk* doclnk; }; class AddAtt : public QDialog { Q_OBJECT public: AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); QStringList returnAttatchedFiles(); QStringList returnFileTypes(); void getFiles(); void clear(); public slots: //void fileCategorySelected(int); void addAttatchment(); void removeAttatchment(); void reject(); void accept(); private: FileItem* item; QListView *attView; - QPushButton *fileCategoryButton, *attatchButton, *removeButton; + QPushButton *attatchButton, *removeButton; QPopupMenu *fileCategories; bool modified; - QFileInfo *fi; + //QFileInfo *fi; - OFileSelector* ofs; + OFileDialog* ofs; }; #endif diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp index 1cf2562..43e3830 100644 --- a/noncore/net/mailit/addresslist.cpp +++ b/noncore/net/mailit/addresslist.cpp @@ -1,167 +1,181 @@ /********************************************************************** ** 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 <qfile.h> #include <qtextstream.h> +#include <opie/ocontactaccess.h> +#include <opie/ocontact.h> #include "addresslist.h" AddressList::AddressList(QString file) { addresses.setAutoDelete(TRUE); filename = file; read(); dirty = FALSE; } AddressList::~AddressList() { write(); addresses.clear(); } void AddressList::addContact(QString email, QString name) { //skip if not a valid email address, if (email.find( '@') == -1) return; if ( ! containsEmail(email) ) { Contact *in = new Contact; in->email = email; in->name = name; addresses.append(in); dirty = TRUE; } } bool AddressList::containsEmail(QString email) { return ( getEmailRef(email) != -1 ); } bool AddressList::containsName(QString name) { return ( getNameRef(name) != -1 ); } QString AddressList::getNameByEmail(QString email) { int pos = getEmailRef(email); if (pos != -1) { Contact *ptr = addresses.at(pos); return ptr->name; } return NULL; } QString AddressList::getEmailByName(QString name) { int pos = getNameRef(name); if (pos != -1) { Contact *ptr = addresses.at(pos); return ptr->email; } return NULL; } int AddressList::getEmailRef(QString email) { int pos = 0; Contact *ptr; for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { if (ptr->email == email) return pos; pos++; } return -1; } int AddressList::getNameRef(QString name) { int pos = 0; Contact *ptr; for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { if (ptr->name == name) return pos; pos++; } return -1; } QList<Contact>* AddressList::getContactList() { return &addresses; } void AddressList::read() { - QFile f(filename); + OContactAccess::List::Iterator it; + + //QFile f(filename); QString lineEmail, lineName, email, name; + OContactAccess m_contactdb("mailit"); + OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); + //OContact* oc; - if (! f.open(IO_ReadOnly) ) + for ( it = m_list.begin(); it != m_list.end(); ++it ) + { + //oc=(OContact*) it; + if ((*it).defaultEmail().length()!=0) + addContact((*it).defaultEmail(),(*it).fullName()); + } + + /*if (! f.open(IO_ReadOnly) ) return; QTextStream stream(&f); while (! stream.atEnd() ) { lineEmail = stream.readLine(); if (! stream.atEnd() ) lineName = stream.readLine(); else return; email = getRightString(lineEmail); name = getRightString(lineName); addContact(email, name); } - f.close(); + f.close();*/ } QString AddressList::getRightString(QString in) { QString out = ""; int pos = in.find('='); if (pos != -1) { out = in.mid(pos+1).stripWhiteSpace(); } return out; } void AddressList::write() { if ( (addresses.count() == 0) || (!dirty) ) return; QFile f(filename); if (! f.open(IO_WriteOnly) ) return; QTextStream stream(&f); Contact *ptr; for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { stream << "email = " + ptr->email + "\n"; stream << "name = " + ptr->name + "\n"; } f.close(); } diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 9258aac..2943986 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp @@ -1,535 +1,535 @@ /********************************************************************** ** 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); + 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()) ); composeButton->addTo(bar); 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); 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->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->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) { QMessageBox::warning(qApp->activeWindow(), tr("No account selected"), tr("You must create an account"), "OK\n"); return; } 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()); diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp index f9b6de2..fd49c1f 100644 --- a/noncore/net/mailit/mailitwindow.cpp +++ b/noncore/net/mailit/mailitwindow.cpp @@ -1,132 +1,136 @@ /********************************************************************** ** 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 "mailitwindow.h" MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { currentCaption = "Mailit"; setCaption(tr(currentCaption)); views = new QWidgetStack(this); setCentralWidget(views); + qWarning("***Starting writeMail"); emailClient = new EmailClient(views, "client"); writeMail = new WriteMail(views, "writing"); readMail = new ReadMail(views, "reading"); + qWarning("***Finished readMail"); views->raiseWidget(emailClient); connect(emailClient, SIGNAL(composeRequested()), this, SLOT(compose()) ); connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, SLOT(viewMail(QListView *, Email *)) ); connect(emailClient, SIGNAL(mailUpdated(Email *)), this, SLOT(updateMailView(Email *)) ); 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(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; + + qWarning("***Finished MailitWindow"); } MailItWindow::~MailItWindow() { } void MailItWindow::closeEvent(QCloseEvent *e) { if (views->visibleWidget() == emailClient) { e->accept(); } else { showEmailClient(); } } 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) { compose(); writeMail->reply(mail); } void MailItWindow::showEmailClient() { viewingMail = FALSE; writeMail->hide(); readMail->hide(); views->raiseWidget(emailClient); setCaption( tr(currentCaption) ); } void MailItWindow::viewMail(QListView *view, Email *mail) { viewingMail = TRUE; emailClient->hide(); readMail->update(view, mail); views->raiseWidget(readMail); setCaption( tr( "Examine mail" ) ); } void MailItWindow::updateMailView(Email *mail) { if (viewingMail) { readMail->mailUpdated(mail); } } void MailItWindow::updateCaption(const QString &newCaption) { currentCaption = newCaption; setCaption(tr(currentCaption)); } void MailItWindow::setDocument(const QString &_address) { // strip leading 'mailto:' QString address = _address; if (address.startsWith("mailto:")) address = address.mid(6); compose(); writeMail->setRecipient(address); } diff --git a/noncore/net/mailit/viewatt.cpp b/noncore/net/mailit/viewatt.cpp index 86f119f..b6f5015 100644 --- a/noncore/net/mailit/viewatt.cpp +++ b/noncore/net/mailit/viewatt.cpp @@ -1,109 +1,118 @@ /********************************************************************** ** 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 "resource.h" #include "viewatt.h" #include <qpe/applnk.h> +#include <qpe/mimetype.h> ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { setCaption("Exploring attatchments"); setToolBarsMovable( FALSE ); bar = new QToolBar(this); installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); listView = new QListView(this, "AttView"); listView->addColumn( "Attatchment" ); listView->addColumn( "Type" ); listView->addColumn( "Installed" ); setCentralWidget(listView); } void ViewAtt::update(Email *mailIn, bool inbox) { QListViewItem *item; Enclosure *ePtr; + + listView->clear(); if (inbox) { bar->clear(); installButton->addTo( bar ); bar->show(); } else { bar->hide(); } mail = mailIn; for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { QString isInstalled = "No"; if (ePtr->installed) isInstalled = "Yes"; item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); + const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; + + MimeType mt(mtypeDef); + + item->setPixmap(0, mt.pixmap()); + + /* if (ePtr->contentType == "TEXT") { actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); actions->addTo(bar); - item->setPixmap(0, Resource::loadPixmap("txt")); - } + } if (ePtr->contentType == "AUDIO") { actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); actions->addTo(bar); item->setPixmap(0, Resource::loadPixmap("play")); } if (ePtr->contentType == "IMAGE") { actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); actions->addTo(bar); item->setPixmap(0, Resource::loadPixmap("pixmap")); - } + }*/ } } void ViewAtt::install() { Enclosure *ePtr, *selPtr; QListViewItem *item; QString filename; DocLnk d; item = listView->selectedItem(); if (item != NULL) { filename = item->text(0); selPtr = NULL; for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { if (ePtr->originalName == filename) selPtr = ePtr; } if (selPtr == NULL) { qWarning("Internal error, file is not installed to documents"); return; } d.setName(selPtr->originalName); d.setFile(selPtr->path + selPtr->name); d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); d.writeLink(); selPtr->installed = TRUE; item->setText(2, "Yes"); } } diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp index 70332a9..a45cfd2 100644 --- a/noncore/net/mailit/writemail.cpp +++ b/noncore/net/mailit/writemail.cpp @@ -1,297 +1,298 @@ /********************************************************************** ** 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 <qmessagebox.h> #include "writemail.h" #include "resource.h" WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { showingAddressList = FALSE; init(); addAtt = new AddAtt(0, "Add Attatchments"); } WriteMail::~WriteMail() { delete addAtt; } void WriteMail::setAddressList(AddressList *list) { Contact *cPtr; addressList = list; addressView->clear(); QList<Contact> *cListPtr = addressList->getContactList(); QListViewItem *item; for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { - item = new QListViewItem(addressView, cPtr->email, cPtr->name); + item = new QListViewItem(addressView, cPtr->name, cPtr->email); } } void WriteMail::init() { setToolBarsMovable(FALSE); bar = new QToolBar(this); bar->setHorizontalStretchable( TRUE ); menu = new QMenuBar( bar ); mailMenu = new QPopupMenu(menu); menu->insertItem( tr( "&Mail" ), mailMenu); addMenu = new QPopupMenu(menu); menu->insertItem( tr( "&Add" ), addMenu); bar = new QToolBar(this); attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); attatchButton->addTo(bar); attatchButton->addTo(addMenu); connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); confirmButton->addTo(bar); confirmButton->addTo(mailMenu); connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 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->setCurrentItem(0); grid->addWidget( recipientsBox, 0, 0 ); 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 ); 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); + addressView = new QListView( widget, "addressView"); - addressView->addColumn("Email"); addressView->addColumn("Name"); + addressView->addColumn("EMail"); addressView->setAllColumnsShowFocus(TRUE); addressView->setMultiSelection(TRUE); addressView->hide(); grid->addMultiCellWidget( addressView, 3, 3, 0, 2); okButton = new QToolButton(bar, "ok"); okButton->setPixmap( Resource::loadPixmap("enter") ); okButton->hide(); connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); setCentralWidget(widget); } void WriteMail::reject() { emit cancelMail(); } // 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"); return; } if (! getRecipients() ) { QMessageBox::warning(this,"Incorrect recipient separator", "Recipients must be separated by ;\nand be valid emailaddresses", "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 += mail.from; mail.rawMail += "\nSubject: "; mail.rawMail += mail.subject; mail.rawMail += "\n\n"; attatchedFiles = addAtt->returnAttatchedFiles(); attatchmentsType = addAtt->returnFileTypes(); QStringList::Iterator itType = attatchmentsType.begin(); Enclosure e; for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { e.id = idCount; e.originalName = (*it).latin1(); e.contentType = (*itType).latin1(); e.contentAttribute = (*itType).latin1(); e.saved = TRUE; mail.addEnclosure(&e); itType++; idCount++; } mail.rawMail += mail.body; mail.rawMail += "\n"; mail.rawMail += ".\n"; emit sendMailRequested(mail); addAtt->clear(); } void WriteMail::getAddress() { showingAddressList = !showingAddressList; if (showingAddressList) { emailInput->hide(); addressView->show(); okButton->show(); } else { addressView->hide(); okButton->hide(); emailInput->show(); } } void WriteMail::attatchFile() { addAtt->showMaximized(); } void WriteMail::reply(Email replyMail) { int pos; mail = replyMail; mail.files.clear(); toInput->setText(mail.fromMail); subjectInput->setText("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() { QString str, temp; int pos = 0; mail.recipients.clear(); 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); addressList->addContact(str, ""); } temp = temp.stripWhiteSpace(); if ( temp.find('@') == -1) return false; mail.recipients.append(temp); addressList->addContact(temp, ""); return TRUE; } void WriteMail::addRecipients() { 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); addressView->hide(); okButton->hide(); emailInput->show(); addressButton->setOn(FALSE); showingAddressList = !showingAddressList; } void WriteMail::setRecipient(const QString &recipient) { toInput->setText(recipient); } void WriteMail::newMail() { toInput->clear(); subjectInput->clear(); emailInput->clear(); //to clear selected setAddressList(addressList); } diff --git a/noncore/unsupported/mailit/addatt.cpp b/noncore/unsupported/mailit/addatt.cpp index f279f52..c8be865 100644 --- a/noncore/unsupported/mailit/addatt.cpp +++ b/noncore/unsupported/mailit/addatt.cpp @@ -1,230 +1,224 @@ /********************************************************************** ** 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 <qlayout.h> +#include <qhbox.h> #include <qdir.h> #include <qstringlist.h> #include "resource.h" #include "addatt.h" FileItem::FileItem(QListView *parent, DocLnk* dl) : QListViewItem(parent) { /*file = fileInfo; type = fileType;*/ doclnk=dl; setText(0, doclnk->name()); /* if (fileType == "Picture") { setPixmap(0, Resource::loadPixmap("pixmap")); } else if (fileType == "Document") { setPixmap(0, Resource::loadPixmap("txt")); } else if (fileType == "Sound") { setPixmap(0, Resource::loadPixmap("play")); } else if (fileType == "Movie") { setPixmap(0, Resource::loadPixmap("MPEGPlayer")); } else if (fileType == "File") { setPixmap(0, Resource::loadPixmap("exec")); }*/ } FileItem::~FileItem() { if (doclnk!=NULL) delete doclnk; doclnk=NULL; } AddAtt::AddAtt(QWidget *parent, const char *name, WFlags f) : QDialog(parent, name, f) { setCaption("Adding attatchments"); - QGridLayout *top = new QGridLayout(this, 3,1 ); + QGridLayout *top = new QGridLayout(this, 1,1 ); - + QHBox *buttons=new QHBox(this); /*fileCategoryButton = new QPushButton(this);*/ - attatchButton = new QPushButton("Attatch ->", this); - removeButton = new QPushButton("Remove", this); + attatchButton = new QPushButton("Attatch ->", buttons); + removeButton = new QPushButton("Remove", buttons); /*fileCategories = new QPopupMenu(fileCategoryButton); fileCategoryButton->setPopup(fileCategories); fileCategories->insertItem("Document"); fileCategories->insertItem("Picture"); fileCategories->insertItem("Sound"); fileCategories->insertItem("Movie"); fileCategories->insertItem("File"); fileCategoryButton->setText("Document"); top->addWidget(fileCategoryButton, 0, 0);*/ - //ofs=new OFileSelector(this,2,0,"/root/Documents"); - - - top->addWidget(attatchButton,1,0); - top->addWidget(removeButton,2,0); - /*connect(fileCategories, SIGNAL(activated(int)), this, - SLOT(fileCategorySelected(int)) );*/ + top->addWidget(buttons,1,0); + //buttons->addWidget(attatchButton,0,0); + //buttons->addWidget(removeButton,0,1); + + //connect(fileCategories, SIGNAL(activated(int)), this, + // SLOT(fileCategorySelected(int)) );*/ connect(attatchButton, SIGNAL(clicked()), this, SLOT(addAttatchment()) ); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeAttatchment()) ); /*listView = new QListView(this, "AttView"); listView->addColumn("Documents");* connect(listView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(addAttatchment()) );*/ attView = new QListView(this, "Selected"); attView->addColumn(tr("Attached")); attView->addColumn(tr("File type")); connect(attView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(removeAttatchment()) ); //top->addWidget(ofs, 0,0); top->addWidget(attView, 0,0); clear(); } void AddAtt::clear() { attView->clear(); //getFiles(); modified = FALSE; } /*void AddAtt::fileCategorySelected(int id) { fileCategoryButton->setText(fileCategories->text(id)); getFiles(); }*/ void AddAtt::addAttatchment() { - QDialog qd(this,tr("Select attachment"),true); - - QGridLayout top(&qd,1,1); - - OFileSelector ofs(&qd,1,0,"/root/Documents"); - - top.addWidget(&ofs,0,0); + OFileDialog ofs("Attachments",this,0,0,"/root/Documents"); - qd.showMaximized(); + ofs.showMaximized(); - if (qd.exec()==QDialog::Accepted) + if (ofs.exec()==QDialog::Accepted) { DocLnk* dl=new DocLnk(ofs.selectedDocument()); FileItem* fi=new FileItem(attView,dl); fi->setPixmap(0,dl->pixmap()); fi->setText(1,dl->type()); attView->insertItem(fi); modified = TRUE; } } void AddAtt::removeAttatchment() { if (attView->selectedItem() != NULL) { attView->takeItem(attView->selectedItem()); } modified = TRUE; } void AddAtt::reject() { if (modified) { attView->clear(); modified = FALSE; } } void AddAtt::accept() { modified = FALSE; hide(); } void AddAtt::getFiles() { QString path, selected; /*listView->clear(); selected = fileCategoryButton->text(); if (selected == "Picture") { path = "../pics/"; } else if (selected == "Document") { path = "" ; //sub-dirs not decided } else if (selected == "Sound") { path = "../sounds/"; //sub-dirs not decided } else if (selected == "Movie") { path = ""; //sub-dirs not decided } else if (selected == "File") { path = ""; //sub-dirs not decided } dir = new QDir(path); dir->setFilter(QDir::Files); const QFileInfoList *dirInfoList = dir->entryInfoList(); QFileInfoListIterator it(*dirInfoList); // create list iterator while ( (fi=it.current()) ) { // for each file... item = new FileItem(lis+ütView, *fi, selected); ++it; // goto next list element }*/ } QStringList AddAtt::returnAttatchedFiles() { QFileInfo info; QStringList list; item = (FileItem *) attView->firstChild(); while (item != NULL) { DocLnk* dl=item->getDocLnk(); list+=dl->file(); /*info = item->getFileInfo(); list += info.filePath();*/ item = (FileItem *) item->nextSibling(); } return list; } QStringList AddAtt::returnFileTypes() { QStringList list; item = (FileItem *) attView->firstChild(); while (item != NULL) { list += item->getDocLnk()->type(); item = (FileItem *) item->nextSibling(); } return list; } diff --git a/noncore/unsupported/mailit/addatt.h b/noncore/unsupported/mailit/addatt.h index 73062e2..fcf3279 100644 --- a/noncore/unsupported/mailit/addatt.h +++ b/noncore/unsupported/mailit/addatt.h @@ -1,76 +1,76 @@ /********************************************************************** ** 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 ADDATT_H #define ADDATT_H #include <qdialog.h> #include <qlistview.h> #include <qpushbutton.h> #include <qpopupmenu.h> #include <qstring.h> #include <qfileinfo.h> #include <qstringlist.h> -#include <opie/ofileselector.h> +#include <opie/ofiledialog.h> #include <qpe/applnk.h> class FileItem : public QListViewItem { public: //FileItem(QListView *parent, QFileInfo fileInfo, QString fileType); FileItem(QListView*, DocLnk*); ~FileItem(); DocLnk* getDocLnk() {return doclnk;} private: DocLnk* doclnk; }; class AddAtt : public QDialog { Q_OBJECT public: AddAtt(QWidget *parent = 0, const char *name = 0, WFlags f = 0); QStringList returnAttatchedFiles(); QStringList returnFileTypes(); void getFiles(); void clear(); public slots: //void fileCategorySelected(int); void addAttatchment(); void removeAttatchment(); void reject(); void accept(); private: FileItem* item; QListView *attView; - QPushButton *fileCategoryButton, *attatchButton, *removeButton; + QPushButton *attatchButton, *removeButton; QPopupMenu *fileCategories; bool modified; - QFileInfo *fi; + //QFileInfo *fi; - OFileSelector* ofs; + OFileDialog* ofs; }; #endif diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp index 1cf2562..43e3830 100644 --- a/noncore/unsupported/mailit/addresslist.cpp +++ b/noncore/unsupported/mailit/addresslist.cpp @@ -1,167 +1,181 @@ /********************************************************************** ** 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 <qfile.h> #include <qtextstream.h> +#include <opie/ocontactaccess.h> +#include <opie/ocontact.h> #include "addresslist.h" AddressList::AddressList(QString file) { addresses.setAutoDelete(TRUE); filename = file; read(); dirty = FALSE; } AddressList::~AddressList() { write(); addresses.clear(); } void AddressList::addContact(QString email, QString name) { //skip if not a valid email address, if (email.find( '@') == -1) return; if ( ! containsEmail(email) ) { Contact *in = new Contact; in->email = email; in->name = name; addresses.append(in); dirty = TRUE; } } bool AddressList::containsEmail(QString email) { return ( getEmailRef(email) != -1 ); } bool AddressList::containsName(QString name) { return ( getNameRef(name) != -1 ); } QString AddressList::getNameByEmail(QString email) { int pos = getEmailRef(email); if (pos != -1) { Contact *ptr = addresses.at(pos); return ptr->name; } return NULL; } QString AddressList::getEmailByName(QString name) { int pos = getNameRef(name); if (pos != -1) { Contact *ptr = addresses.at(pos); return ptr->email; } return NULL; } int AddressList::getEmailRef(QString email) { int pos = 0; Contact *ptr; for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { if (ptr->email == email) return pos; pos++; } return -1; } int AddressList::getNameRef(QString name) { int pos = 0; Contact *ptr; for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { if (ptr->name == name) return pos; pos++; } return -1; } QList<Contact>* AddressList::getContactList() { return &addresses; } void AddressList::read() { - QFile f(filename); + OContactAccess::List::Iterator it; + + //QFile f(filename); QString lineEmail, lineName, email, name; + OContactAccess m_contactdb("mailit"); + OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); + //OContact* oc; - if (! f.open(IO_ReadOnly) ) + for ( it = m_list.begin(); it != m_list.end(); ++it ) + { + //oc=(OContact*) it; + if ((*it).defaultEmail().length()!=0) + addContact((*it).defaultEmail(),(*it).fullName()); + } + + /*if (! f.open(IO_ReadOnly) ) return; QTextStream stream(&f); while (! stream.atEnd() ) { lineEmail = stream.readLine(); if (! stream.atEnd() ) lineName = stream.readLine(); else return; email = getRightString(lineEmail); name = getRightString(lineName); addContact(email, name); } - f.close(); + f.close();*/ } QString AddressList::getRightString(QString in) { QString out = ""; int pos = in.find('='); if (pos != -1) { out = in.mid(pos+1).stripWhiteSpace(); } return out; } void AddressList::write() { if ( (addresses.count() == 0) || (!dirty) ) return; QFile f(filename); if (! f.open(IO_WriteOnly) ) return; QTextStream stream(&f); Contact *ptr; for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { stream << "email = " + ptr->email + "\n"; stream << "name = " + ptr->name + "\n"; } f.close(); } diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 9258aac..2943986 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp @@ -1,535 +1,535 @@ /********************************************************************** ** 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); + 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()) ); composeButton->addTo(bar); 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); 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->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->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) { QMessageBox::warning(qApp->activeWindow(), tr("No account selected"), tr("You must create an account"), "OK\n"); return; } 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()); diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp index f9b6de2..fd49c1f 100644 --- a/noncore/unsupported/mailit/mailitwindow.cpp +++ b/noncore/unsupported/mailit/mailitwindow.cpp @@ -1,132 +1,136 @@ /********************************************************************** ** 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 "mailitwindow.h" MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { currentCaption = "Mailit"; setCaption(tr(currentCaption)); views = new QWidgetStack(this); setCentralWidget(views); + qWarning("***Starting writeMail"); emailClient = new EmailClient(views, "client"); writeMail = new WriteMail(views, "writing"); readMail = new ReadMail(views, "reading"); + qWarning("***Finished readMail"); views->raiseWidget(emailClient); connect(emailClient, SIGNAL(composeRequested()), this, SLOT(compose()) ); connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, SLOT(viewMail(QListView *, Email *)) ); connect(emailClient, SIGNAL(mailUpdated(Email *)), this, SLOT(updateMailView(Email *)) ); 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(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; + + qWarning("***Finished MailitWindow"); } MailItWindow::~MailItWindow() { } void MailItWindow::closeEvent(QCloseEvent *e) { if (views->visibleWidget() == emailClient) { e->accept(); } else { showEmailClient(); } } 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) { compose(); writeMail->reply(mail); } void MailItWindow::showEmailClient() { viewingMail = FALSE; writeMail->hide(); readMail->hide(); views->raiseWidget(emailClient); setCaption( tr(currentCaption) ); } void MailItWindow::viewMail(QListView *view, Email *mail) { viewingMail = TRUE; emailClient->hide(); readMail->update(view, mail); views->raiseWidget(readMail); setCaption( tr( "Examine mail" ) ); } void MailItWindow::updateMailView(Email *mail) { if (viewingMail) { readMail->mailUpdated(mail); } } void MailItWindow::updateCaption(const QString &newCaption) { currentCaption = newCaption; setCaption(tr(currentCaption)); } void MailItWindow::setDocument(const QString &_address) { // strip leading 'mailto:' QString address = _address; if (address.startsWith("mailto:")) address = address.mid(6); compose(); writeMail->setRecipient(address); } diff --git a/noncore/unsupported/mailit/viewatt.cpp b/noncore/unsupported/mailit/viewatt.cpp index 86f119f..b6f5015 100644 --- a/noncore/unsupported/mailit/viewatt.cpp +++ b/noncore/unsupported/mailit/viewatt.cpp @@ -1,109 +1,118 @@ /********************************************************************** ** 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 "resource.h" #include "viewatt.h" #include <qpe/applnk.h> +#include <qpe/mimetype.h> ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { setCaption("Exploring attatchments"); setToolBarsMovable( FALSE ); bar = new QToolBar(this); installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); listView = new QListView(this, "AttView"); listView->addColumn( "Attatchment" ); listView->addColumn( "Type" ); listView->addColumn( "Installed" ); setCentralWidget(listView); } void ViewAtt::update(Email *mailIn, bool inbox) { QListViewItem *item; Enclosure *ePtr; + + listView->clear(); if (inbox) { bar->clear(); installButton->addTo( bar ); bar->show(); } else { bar->hide(); } mail = mailIn; for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { QString isInstalled = "No"; if (ePtr->installed) isInstalled = "Yes"; item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); + const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; + + MimeType mt(mtypeDef); + + item->setPixmap(0, mt.pixmap()); + + /* if (ePtr->contentType == "TEXT") { actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); actions->addTo(bar); - item->setPixmap(0, Resource::loadPixmap("txt")); - } + } if (ePtr->contentType == "AUDIO") { actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); actions->addTo(bar); item->setPixmap(0, Resource::loadPixmap("play")); } if (ePtr->contentType == "IMAGE") { actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); actions->addTo(bar); item->setPixmap(0, Resource::loadPixmap("pixmap")); - } + }*/ } } void ViewAtt::install() { Enclosure *ePtr, *selPtr; QListViewItem *item; QString filename; DocLnk d; item = listView->selectedItem(); if (item != NULL) { filename = item->text(0); selPtr = NULL; for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { if (ePtr->originalName == filename) selPtr = ePtr; } if (selPtr == NULL) { qWarning("Internal error, file is not installed to documents"); return; } d.setName(selPtr->originalName); d.setFile(selPtr->path + selPtr->name); d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); d.writeLink(); selPtr->installed = TRUE; item->setText(2, "Yes"); } } diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp index 70332a9..a45cfd2 100644 --- a/noncore/unsupported/mailit/writemail.cpp +++ b/noncore/unsupported/mailit/writemail.cpp @@ -1,297 +1,298 @@ /********************************************************************** ** 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 <qmessagebox.h> #include "writemail.h" #include "resource.h" WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { showingAddressList = FALSE; init(); addAtt = new AddAtt(0, "Add Attatchments"); } WriteMail::~WriteMail() { delete addAtt; } void WriteMail::setAddressList(AddressList *list) { Contact *cPtr; addressList = list; addressView->clear(); QList<Contact> *cListPtr = addressList->getContactList(); QListViewItem *item; for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { - item = new QListViewItem(addressView, cPtr->email, cPtr->name); + item = new QListViewItem(addressView, cPtr->name, cPtr->email); } } void WriteMail::init() { setToolBarsMovable(FALSE); bar = new QToolBar(this); bar->setHorizontalStretchable( TRUE ); menu = new QMenuBar( bar ); mailMenu = new QPopupMenu(menu); menu->insertItem( tr( "&Mail" ), mailMenu); addMenu = new QPopupMenu(menu); menu->insertItem( tr( "&Add" ), addMenu); bar = new QToolBar(this); attatchButton = new QAction(tr("Attatchment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); attatchButton->addTo(bar); attatchButton->addTo(addMenu); connect( attatchButton, SIGNAL( activated() ), this, SLOT( attatchFile() ) ); confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); confirmButton->addTo(bar); confirmButton->addTo(mailMenu); connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); 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->setCurrentItem(0); grid->addWidget( recipientsBox, 0, 0 ); 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 ); 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); + addressView = new QListView( widget, "addressView"); - addressView->addColumn("Email"); addressView->addColumn("Name"); + addressView->addColumn("EMail"); addressView->setAllColumnsShowFocus(TRUE); addressView->setMultiSelection(TRUE); addressView->hide(); grid->addMultiCellWidget( addressView, 3, 3, 0, 2); okButton = new QToolButton(bar, "ok"); okButton->setPixmap( Resource::loadPixmap("enter") ); okButton->hide(); connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); setCentralWidget(widget); } void WriteMail::reject() { emit cancelMail(); } // 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"); return; } if (! getRecipients() ) { QMessageBox::warning(this,"Incorrect recipient separator", "Recipients must be separated by ;\nand be valid emailaddresses", "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 += mail.from; mail.rawMail += "\nSubject: "; mail.rawMail += mail.subject; mail.rawMail += "\n\n"; attatchedFiles = addAtt->returnAttatchedFiles(); attatchmentsType = addAtt->returnFileTypes(); QStringList::Iterator itType = attatchmentsType.begin(); Enclosure e; for ( QStringList::Iterator it = attatchedFiles.begin(); it != attatchedFiles.end(); ++it ) { e.id = idCount; e.originalName = (*it).latin1(); e.contentType = (*itType).latin1(); e.contentAttribute = (*itType).latin1(); e.saved = TRUE; mail.addEnclosure(&e); itType++; idCount++; } mail.rawMail += mail.body; mail.rawMail += "\n"; mail.rawMail += ".\n"; emit sendMailRequested(mail); addAtt->clear(); } void WriteMail::getAddress() { showingAddressList = !showingAddressList; if (showingAddressList) { emailInput->hide(); addressView->show(); okButton->show(); } else { addressView->hide(); okButton->hide(); emailInput->show(); } } void WriteMail::attatchFile() { addAtt->showMaximized(); } void WriteMail::reply(Email replyMail) { int pos; mail = replyMail; mail.files.clear(); toInput->setText(mail.fromMail); subjectInput->setText("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() { QString str, temp; int pos = 0; mail.recipients.clear(); 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); addressList->addContact(str, ""); } temp = temp.stripWhiteSpace(); if ( temp.find('@') == -1) return false; mail.recipients.append(temp); addressList->addContact(temp, ""); return TRUE; } void WriteMail::addRecipients() { 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); addressView->hide(); okButton->hide(); emailInput->show(); addressButton->setOn(FALSE); showingAddressList = !showingAddressList; } void WriteMail::setRecipient(const QString &recipient) { toInput->setText(recipient); } void WriteMail::newMail() { toInput->clear(); subjectInput->clear(); emailInput->clear(); //to clear selected setAddressList(addressList); } |