summaryrefslogtreecommitdiff
authorgroucho <groucho>2003-04-14 08:22:55 (UTC)
committer groucho <groucho>2003-04-14 08:22:55 (UTC)
commit4624a73cd100f860371fb01facea442737e9336e (patch) (side-by-side diff)
treeae06cfd24013ca39816a5ca035605988f4033dcd
parent6d737040698a9c7ebc6492ba4234b64bf4db6c0b (diff)
downloadopie-4624a73cd100f860371fb01facea442737e9336e.zip
opie-4624a73cd100f860371fb01facea442737e9336e.tar.gz
opie-4624a73cd100f860371fb01facea442737e9336e.tar.bz2
- Buttonlayout changed in attach dialog
- Removed file access for address list (reduces size) - Added header size sping box for accounts - mailit shows an icon in the message list if attachments are present - Added translations in pro file - Removed resource.* references in header files, uses qpe/resource.h instead
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mailit/addatt.cpp6
-rw-r--r--noncore/net/mailit/addresslist.cpp22
-rw-r--r--noncore/net/mailit/addresslist.h3
-rw-r--r--noncore/net/mailit/editaccount.cpp27
-rw-r--r--noncore/net/mailit/editaccount.h3
-rw-r--r--noncore/net/mailit/emailclient.cpp12
-rw-r--r--noncore/net/mailit/emailhandler.cpp19
-rw-r--r--noncore/net/mailit/emailhandler.h1
-rw-r--r--noncore/net/mailit/emaillistitem.cpp5
-rw-r--r--noncore/net/mailit/mailit.pro17
-rw-r--r--noncore/net/mailit/readmail.cpp2
-rw-r--r--noncore/net/mailit/writemail.cpp2
-rw-r--r--noncore/unsupported/mailit/addatt.cpp6
-rw-r--r--noncore/unsupported/mailit/addresslist.cpp22
-rw-r--r--noncore/unsupported/mailit/addresslist.h3
-rw-r--r--noncore/unsupported/mailit/editaccount.cpp27
-rw-r--r--noncore/unsupported/mailit/editaccount.h3
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp12
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp19
-rw-r--r--noncore/unsupported/mailit/emailhandler.h1
-rw-r--r--noncore/unsupported/mailit/emaillistitem.cpp5
-rw-r--r--noncore/unsupported/mailit/mailit.pro17
-rw-r--r--noncore/unsupported/mailit/readmail.cpp2
-rw-r--r--noncore/unsupported/mailit/writemail.cpp2
24 files changed, 154 insertions, 84 deletions
diff --git a/noncore/net/mailit/addatt.cpp b/noncore/net/mailit/addatt.cpp
index c8be865..d268f1f 100644
--- a/noncore/net/mailit/addatt.cpp
+++ b/noncore/net/mailit/addatt.cpp
@@ -1,162 +1,162 @@
/**********************************************************************
** 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 <qpe/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, 1,1 );
QHBox *buttons=new QHBox(this);
/*fileCategoryButton = new QPushButton(this);*/
- attatchButton = new QPushButton("Attatch ->", buttons);
- removeButton = new QPushButton("Remove", buttons);
+ attatchButton = new QPushButton(tr("Attatch..."), buttons);
+ removeButton = new QPushButton(tr("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);*/
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()
{
OFileDialog ofs("Attachments",this,0,0,"/root/Documents");
ofs.showMaximized();
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();
}
diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp
index 43e3830..9fe558a 100644
--- a/noncore/net/mailit/addresslist.cpp
+++ b/noncore/net/mailit/addresslist.cpp
@@ -1,181 +1,161 @@
/**********************************************************************
** 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)
+AddressList::AddressList()
{
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()
{
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;
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();*/
}
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/addresslist.h b/noncore/net/mailit/addresslist.h
index e87d6f1..99cef9a 100644
--- a/noncore/net/mailit/addresslist.h
+++ b/noncore/net/mailit/addresslist.h
@@ -1,59 +1,58 @@
/**********************************************************************
** 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 ADDRESSLIST_H
#define ADDRESSLIST_H
#include <qobject.h>
#include <qlist.h>
struct Contact
{
QString email;
QString name;
};
class AddressList : public QObject
{
Q_OBJECT
public:
- AddressList(QString file);
+ AddressList();
~AddressList();
void addContact(QString email, QString name);
bool containsEmail(QString email);
bool containsName(QString name);
QString getNameByEmail(QString email);
QString getEmailByName(QString name);
QList<Contact>* getContactList();
- void write();
private:
int getEmailRef(QString email);
int getNameRef(QString name);
QString getRightString(QString in);
void read();
private:
QList<Contact> addresses;
QString filename;
bool dirty;
};
#endif
diff --git a/noncore/net/mailit/editaccount.cpp b/noncore/net/mailit/editaccount.cpp
index c4f95ea..c0afbb2 100644
--- a/noncore/net/mailit/editaccount.cpp
+++ b/noncore/net/mailit/editaccount.cpp
@@ -1,120 +1,133 @@
/**********************************************************************
** 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 <qhbox.h>
#include "editaccount.h"
EditAccount::EditAccount( QWidget* parent, const char* name, WFlags fl )
: QDialog(parent, name, fl)
{
setCaption( tr("Edit Account") );
init();
popPasswInput->setEchoMode(QLineEdit::Password);
}
void EditAccount::setAccount(MailAccount *in, bool newOne)
{
account = in;
if (newOne) {
accountNameInput->setText("");
nameInput->setText("");
emailInput->setText("");
popUserInput->setText("");
popPasswInput->setText("");
popServerInput->setText("");
smtpServerInput->setText("");
syncCheckBox->setChecked(TRUE);
+ syncLimitInput->setValue(2);
setCaption( tr("Create new Account") );
} else {
accountNameInput->setText(account->accountName);
nameInput->setText(account->name);
emailInput->setText(account->emailAddress);
popUserInput->setText(account->popUserName);
popPasswInput->setText(account->popPasswd);
popServerInput->setText(account->popServer);
smtpServerInput->setText(account->smtpServer);
syncCheckBox->setChecked(account->synchronize);
+ syncLimitInput->setValue(account->syncLimit/1000);
}
}
void EditAccount::init()
{
grid = new QGridLayout(this);
grid->setSpacing( 6 );
grid->setMargin( 11 );
accountNameInputLabel = new QLabel(tr("Account name"), this);
grid->addWidget( accountNameInputLabel, 0, 0 );
accountNameInput = new QLineEdit( this, "account nameInput" );
grid->addWidget( accountNameInput, 0, 1 );
nameInputLabel = new QLabel(tr("Your name"), this);
grid->addWidget( nameInputLabel, 1, 0 );
nameInput = new QLineEdit( this, "nameInput" );
grid->addWidget( nameInput, 1, 1 );
- emailInputLabel = new QLabel("Email", this);
+ emailInputLabel = new QLabel(tr("Email"), this);
grid->addWidget(emailInputLabel, 2, 0 );
emailInput = new QLineEdit( this, "emailInput" );
grid->addWidget( emailInput, 2, 1 );
- popUserInputLabel = new QLabel("POP username", this);
+ popUserInputLabel = new QLabel(tr("POP username"), this);
grid->addWidget( popUserInputLabel, 3, 0 );
popUserInput = new QLineEdit( this, "popUserInput" );
grid->addWidget( popUserInput, 3, 1 );
- popPasswInputLabel = new QLabel( "POP password", this);
+ popPasswInputLabel = new QLabel( tr("POP password"), this);
grid->addWidget( popPasswInputLabel, 4, 0 );
popPasswInput = new QLineEdit( this, "popPasswInput" );
grid->addWidget( popPasswInput, 4, 1 );
- popServerInputLabel = new QLabel("POP server", this);
+ popServerInputLabel = new QLabel(tr("POP server"), this);
grid->addWidget( popServerInputLabel, 5, 0 );
popServerInput = new QLineEdit( this, "popServerInput" );
grid->addWidget( popServerInput, 5, 1 );
- smtpServerInputLabel = new QLabel("SMTP server", this );
+ smtpServerInputLabel = new QLabel(tr("SMTP server"), this );
grid->addWidget( smtpServerInputLabel, 6, 0 );
smtpServerInput = new QLineEdit( this, "smtpServerInput" );
grid->addWidget( smtpServerInput, 6, 1 );
- syncCheckBox = new QCheckBox( tr( "Synchronize with server" ), this);
+ QHBox* syncBox=new QHBox(this);
+ grid->addWidget( syncBox, 7, 1 );
+
+ syncCheckBox = new QCheckBox( tr( "Synchronize" ), this);
syncCheckBox->setChecked( TRUE );
- grid->addMultiCellWidget( syncCheckBox, 7, 7, 0, 1 );
+ grid->addWidget( syncCheckBox,7,0);
+
+ syncLimitInputLabel = new QLabel(tr("Mail Size (k)"), syncBox);
+ //syncBox->addWidget( syncLimitInputLabel);
+ syncLimitInput = new QSpinBox( syncBox, "syncSize" );
+ //syncBox->addWidget(syncLimitInput);
+
}
void EditAccount::accept()
{
account->accountName = accountNameInput->text();
account->name = nameInput->text();
account->emailAddress = emailInput->text();
account->popUserName = popUserInput->text();
account->popPasswd = popPasswInput->text();
account->popServer = popServerInput->text();
account->smtpServer = smtpServerInput->text();
account->synchronize = syncCheckBox->isChecked();
+ account->syncLimit = syncLimitInput->value()*1000; //Display in kB
QDialog::accept();
}
void EditAccount::reject()
{
}
diff --git a/noncore/net/mailit/editaccount.h b/noncore/net/mailit/editaccount.h
index 7a90e50..1e15047 100644
--- a/noncore/net/mailit/editaccount.h
+++ b/noncore/net/mailit/editaccount.h
@@ -1,66 +1,69 @@
/**********************************************************************
** 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 EDITACCOUNT_H
#define EDITACCOUNT_H
#include <qdialog.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qlayout.h>
+#include <qspinbox.h>
#include "emailhandler.h"
class EditAccount : public QDialog
{
Q_OBJECT
public:
EditAccount( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
void setAccount(MailAccount *in, bool newOne = TRUE);
void init();
public slots:
void accept();
void reject();
private:
MailAccount thisAccount, *account;
QLabel *accountNameInputLabel;
QLabel *nameInputLabel;
QLabel *emailInputLabel;
QLabel *popUserInputLabel;
QLabel *popPasswInputLabel;
QLabel *popServerInputLabel;
QLabel *smtpServerInputLabel;
+ QLabel *syncLimitInputLabel;
QLineEdit *accountNameInput;
QLineEdit *nameInput;
QLineEdit *emailInput;
QLineEdit *popUserInput;
QLineEdit *popPasswInput;
QLineEdit *popServerInput;
QLineEdit *smtpServerInput;
+ QSpinBox *syncLimitInput;
QCheckBox *syncCheckBox;
QGridLayout *grid;
};
#endif
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
index 2943986..6612541 100644
--- a/noncore/net/mailit/emailclient.cpp
+++ b/noncore/net/mailit/emailclient.cpp
@@ -1,140 +1,140 @@
/**********************************************************************
** 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 <qpe/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");
+ addressList = new AddressList();
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);
@@ -578,237 +578,245 @@ void EmailClient::readMail()
void EmailClient::saveMail(QString fileName, QListView *view)
{
QFile f(fileName);
Email *mail;
if (! f.open(IO_WriteOnly) ) {
qWarning("could not open file");
return;
}
item = (EmailListItem *) view->firstChild();
qDebug (QString("Write : ") );
QTextStream t(&f);
while (item != NULL) {
mail = item->getMail();
qDebug(mail->rawMail);
qDebug(mail->recipients.first());
t << mail->rawMail;
mailconf->setGroup(mail->id);
mailconf->writeEntry("mailread", mail->read);
item = (EmailListItem *) item->nextSibling();
}
f.close();
}
//paths for mailit, is settings, inbox, enclosures
QString EmailClient::getPath(bool enclosurePath)
{
QString basePath = "qtmail";
QString enclosures = "enclosures";
QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
if ( !dir.exists() )
dir.mkdir( dir.path() );
if (enclosurePath) {
dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
if ( !dir.exists() )
dir.mkdir( dir.path() );
return (dir.path() + "/");
}
return (dir.path() + "/");
}
void EmailClient::readSettings()
{
TextParser *p;
QString s;
int pos, accountPos, y;
QFile f( getPath(FALSE) + "settings.txt");
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
s = t.read();
f.close();
p = new TextParser(s, "\n");
accountPos = 0;
while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) {
accountPos++;
if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 )
account.accountName = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1)
account.name = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1)
account.emailAddress = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1)
account.popUserName = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1)
account.popPasswd = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1)
account.popServer = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1)
account.smtpServer = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) {
s = p->getString(& ++pos, 'z', TRUE);
account.id = s.toInt();
}
account.lastServerMailCount = 0;
account.synchronize = FALSE;
if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) {
if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") {
account.synchronize = TRUE;
if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) {
s = p->getString(& ++pos, 'z', TRUE);
account.lastServerMailCount = s.toInt();
}
}
}
+
+ if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) {
+ account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt();
+ }
+
+
accountList.append(&account);
}
delete p;
}
mailconf->setGroup("mailitglobal");
if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) {
mailIdCount = y;
}
if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) {
accountIdCount = y;
}
}
void EmailClient::saveSettings()
{
QString temp;
QFile f( getPath(FALSE) + "settings.txt");
MailAccount *accountPtr;
if (! f.open(IO_WriteOnly) ) {
qWarning("could not save settings file");
return;
}
QTextStream t(&f);
t << "#Settings for QPE Mailit program\n";
for (accountPtr = accountList.first(); accountPtr != 0;
accountPtr = accountList.next()) {
t << "accountStart;\n";
t << "AccountName: " + accountPtr->accountName + "\n";
t << "Name: " + accountPtr->name + "\n";
t << "Email: " + accountPtr->emailAddress + "\n";
t << "POPUser: " + accountPtr->popUserName + "\n";
t << "POPPAssword: " + accountPtr->popPasswd + "\n";
t << "POPServer: " + accountPtr->popServer + "\n";
t << "SMTPServer: " + accountPtr->smtpServer + "\n";
t << "AccountId: " << accountPtr->id << "\n";
if (accountPtr->synchronize) {
t << "Synchronize: Yes\n";
t << "LastServerMailCount: ";
t << accountPtr->lastServerMailCount << "\n";
} else {
t << "Synchronize: No\n";
}
+ t << "SyncLimit: ";
+ t << accountPtr->syncLimit << "\n";
t << "accountEnd;\n";
}
f.close();
mailconf->setGroup("mailitglobal");
mailconf->writeEntry("mailidcount", mailIdCount);
mailconf->writeEntry("accountidcount", accountIdCount);
}
void EmailClient::selectAccount(int id)
{
if (accountList.count() > 0) {
currentAccount = accountList.at(id);
emit newCaption("Mailit - " + currentAccount->accountName);
getNewMail();
} else {
emit newCaption("Mailit ! No account defined");
}
}
void EmailClient::editAccount(int id)
{
MailAccount *newAccount;
editAccountView = new EditAccount(this, "account", TRUE);
if (id == newAccountId) { //new account
newAccount = new MailAccount;
editAccountView->setAccount(newAccount);
} else {
newAccount = accountList.at(id);
editAccountView->setAccount(newAccount, FALSE);
}
editAccountView->showMaximized();
editAccountView->exec();
if (editAccountView->result() == QDialog::Accepted) {
if (id == newAccountId) {
newAccount->id = accountIdCount;
accountIdCount++;
accountList.append(newAccount);
updateAccounts();
} else {
updateAccounts();
}
}
delete editAccountView;
}
void EmailClient::deleteAccount(int id)
{
MailAccount *newAccount;
QString message;
newAccount = accountList.at(id);
message = "Delete account:\n" + newAccount->accountName;
switch( QMessageBox::warning( this, "Mailit", message,
"Yes", "No", 0, 0, 1 ) ) {
case 0: accountList.remove(id);
updateAccounts();
break;
case 1:
break;
}
}
void EmailClient::updateAccounts()
{
MailAccount *accountPtr;
//rebuild menus, clear all first
editAccountMenu->clear();
selectAccountMenu->clear();
deleteAccountMenu->clear();
newAccountId = editAccountMenu->insertItem("New", this,
SLOT(editAccount(int)) );
editAccountMenu->insertSeparator();
idCount = 0;
for (accountPtr = accountList.first(); accountPtr != 0;
accountPtr = accountList.next()) {
editAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(editAccount(int)), 0, idCount);
selectAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(selectAccount(int)), 0, idCount);
deleteAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(deleteAccount(int)), 0, idCount);
idCount++;
}
}
void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
index 1be16d4..9c1c814 100644
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/noncore/net/mailit/emailhandler.cpp
@@ -25,286 +25,295 @@
#include "emailhandler.h"
#include <qpe/applnk.h>
#include <qpe/filemanager.h>
QCollection::Item EnclosureList::newItem(QCollection::Item d)
{
return dupl( (Enclosure *) d);
}
Enclosure* EnclosureList::dupl(Enclosure *in)
{
ac = new Enclosure(*in);
return ac;
}
EmailHandler::EmailHandler()
{
smtpClient = new SmtpClient();
popClient = new PopClient();
connect(smtpClient, SIGNAL(errorOccurred(int)), this,
SIGNAL(smtpError(int)) );
connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) );
connect(smtpClient, SIGNAL(updateStatus(const QString &)), this,
SIGNAL(updateSmtpStatus(const QString &)) );
connect(popClient, SIGNAL(errorOccurred(int)), this,
SIGNAL(popError(int)) );
connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)),
this, SLOT(messageArrived(const QString &, int, uint, bool)) );
connect(popClient, SIGNAL(updateStatus(const QString &)), this,
SIGNAL(updatePopStatus(const QString &)) );
connect(popClient, SIGNAL(mailTransfered(int)), this,
SIGNAL(mailTransfered(int)) );
//relaying size information
connect(popClient, SIGNAL(currentMailSize(int)),
this, SIGNAL(currentMailSize(int)) );
connect(popClient, SIGNAL(downloadedSize(int)),
this, SIGNAL(downloadedSize(int)) );
}
void EmailHandler::sendMail(QList<Email> *mailList)
{
Email *currentMail;
QString temp;
QString userName = mailAccount.name;
userName += " <" + mailAccount.emailAddress + ">";
for (currentMail = mailList->first(); currentMail != 0;
currentMail = mailList->next()) {
if (encodeMime(currentMail) == 0) {
smtpClient->addMail(userName, currentMail->subject,
currentMail->recipients, currentMail->rawMail);
} else { //error
temp = tr("Could not locate all files in \nmail with subject: ") +
currentMail->subject;
temp += tr("\nMail has NOT been sent");
QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n"));
}
}
smtpClient->newConnection(mailAccount.smtpServer, 25);
}
void EmailHandler::setAccount(MailAccount account)
{
mailAccount = account;
}
void EmailHandler::getMail()
{
popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
if (mailAccount.synchronize) {
popClient->setSynchronize(mailAccount.lastServerMailCount);
} else {
popClient->removeSynchronize();
}
headers = FALSE;
popClient->headersOnly(headers, 0);
popClient->newConnection(mailAccount.popServer, 110);
}
void EmailHandler::getMailHeaders()
{
popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
if (mailAccount.synchronize) {
popClient->setSynchronize(mailAccount.lastServerMailCount);
} else {
popClient->removeSynchronize();
}
headers = TRUE;
- popClient->headersOnly(headers, 2000); //less than 2000, download all
+ popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all
popClient->newConnection(mailAccount.popServer, 110);
}
void EmailHandler::getMailByList(MailList *mailList)
{
if (mailList->count() == 0) { //should not occur though
emit mailTransfered(0);
return;
}
headers = FALSE;
popClient->headersOnly(FALSE, 0);
popClient->newConnection(mailAccount.popServer, 110);
popClient->setSelectedMails(mailList);
}
void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete)
{
Email mail;
mail.rawMail = message;
mail.serverId = id;
mail.size = size;
mail.downloaded = complete;
emit mailArrived(mail, FALSE);
}
bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
{
QString temp, boundary;
int pos;
QString delimiter, header, body, mimeHeader, mimeBody;
QString content, contentType, contentAttribute, id, encoding;
QString fileName, storedName;
int enclosureId = 0;
mail->rawMail = in;
mail->received = TRUE;
mail->files.setAutoDelete(TRUE);
temp = lineShift + "." + lineShift;
if (in.right(temp.length()) != temp) {
qWarning(in.right(temp.length()));
qWarning(" . added at end of email as separator");
mail->rawMail += temp;
}
delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
pos = in.find(delimiter, 0, FALSE);
header = in.left(pos);
body = in.right(in.length() - pos - delimiter.length());
if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
body.truncate(body.length()-2);
TextParser p(header, lineShift);
if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
pos++;
if (p.separatorAt(pos) == ' ') {
mail->from = p.getString(&pos, '<', false);
mail->from = mail->from.stripWhiteSpace();
if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
mail->from = mail->from.left(mail->from.length() - 1);
mail->from = mail->from.right(mail->from.length() - 1);
}
pos++;
mail->fromMail = p.getString(&pos, '>', false);
} else {
if ((p.separatorAt(pos) == '<')
|| (p.separatorAt(pos) == ' ')) //No name.. nasty
pos++;
pos++;
mail->fromMail = p.getString(&pos, 'z', TRUE);
if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
mail->fromMail.truncate(mail->fromMail.length() - 1);
mail->from=mail->fromMail;
}
}
+
+ //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To:
+ if (pos = p.find("TO",':', pos, TRUE) != -1)
+ {
+ pos++;
+ mail->recipients.append (p.getString(&pos, 'z', TRUE) );
+ }
+
+
+
if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
pos++;
mail->subject = p.getString(&pos, 'z', TRUE);
}
if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
pos++;
mail->date = p.getString(&pos, 'z', true);
}
- if ((pos = p.find("TO",':', 0, TRUE)) != -1) {
- pos++;
- mail->recipients.append (p.getString(&pos, 'z', TRUE) );
- }
+
+
+
if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
pos++;
if ( (p.wordAt(pos).upper() == "ID") &&
(p.separatorAt(pos) == ':') ) {
id = p.getString(&pos, 'z', TRUE);
mail->id = id;
}
}
pos = 0;
while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) {
pos++;
if ( (p.wordAt(pos).upper() == "VERSION") &&
(p.separatorAt(pos) == ':') ) {
pos++;
if (p.getString(&pos, 'z', true) == "1.0") {
mail->mimeType = 1;
}
}
}
if (mail->mimeType == 1) {
boundary = "";
if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) {
pos++;
boundary = p.getString(&pos, 'z', true);
if (boundary[0] == '"') {
boundary = boundary.left(boundary.length() - 1); //strip "
boundary = boundary.right(boundary.length() - 1); //strip "
}
boundary = "--" + boundary; //create boundary field
}
if (boundary == "") { //fooled by Mime-Version
mail->body = body;
mail->bodyPlain = body;
return mail;
}
while (body.length() > 0) {
pos = body.find(boundary, 0, FALSE);
pos = body.find(delimiter, pos, FALSE);
mimeHeader = body.left(pos);
mimeBody = body.right(body.length() - pos - delimiter.length());
TextParser bp(mimeHeader, lineShift);
contentType = "";
contentAttribute = "";
fileName = "";
if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) {
pos++;
if ( (bp.wordAt(pos).upper() == "TYPE") &&
(bp.separatorAt(pos) == ':') ) {
contentType = bp.nextWord().upper();
if (bp.nextSeparator() == '/')
contentAttribute = bp.nextWord().upper();
content = contentType + "/" + contentAttribute;
}
if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) {
pos++;
encoding = bp.getString(&pos, 'z', TRUE);
}
if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) {
pos++;
fileName = bp.getString(&pos, 'z', TRUE);
fileName = fileName.right(fileName.length() - 1);
fileName = fileName.left(fileName.length() - 1);
}
}
pos = mimeBody.find(boundary, 0, FALSE);
if (pos == -1) //should not occur, malformed mail
pos = mimeBody.length();
body = mimeBody.right(mimeBody.length() - pos);
mimeBody = mimeBody.left(pos);
if (fileName != "") { //attatchments of some type, audio, image etc.
Enclosure e;
e.id = enclosureId;
e.originalName = fileName;
e.contentType = contentType;
e.contentAttribute = contentAttribute;
e.encoding = encoding;
e.body = mimeBody;
e.saved = FALSE;
mail->addEnclosure(&e);
enclosureId++;
} else if (contentType == "TEXT") {
if (contentAttribute == "PLAIN") {
mail->body = mimeBody;
mail->bodyPlain = mimeBody;
}
diff --git a/noncore/net/mailit/emailhandler.h b/noncore/net/mailit/emailhandler.h
index 17c4414..e47fd9a 100644
--- a/noncore/net/mailit/emailhandler.h
+++ b/noncore/net/mailit/emailhandler.h
@@ -1,147 +1,148 @@
/**********************************************************************
** 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 EmailHandler_H
#define EmailHandler_H
#include <qobject.h>
#include <qstring.h>
#include <qdatetime.h>
#include <qlist.h>
#include <qstringlist.h>
#include <qfile.h>
#include <qstringlist.h>
#include <qcollection.h>
#include "smtpclient.h"
#include "popclient.h"
#include "textparser.h"
#include "maillist.h"
struct Enclosure
{
int id;
QString originalName;
QString name;
QString path;
QString contentType;
QString contentAttribute;
QString encoding;
QString body; //might use to much mem. check!!
bool saved, installed;
};
class EnclosureList : public QList<Enclosure>
{
public:
Item newItem(Item d);
private:
Enclosure* dupl(Enclosure *in);
Enclosure *ac;
};
struct Email
{
QString id;
QString from;
QString fromMail;
QStringList recipients;
QStringList carbonCopies;
QString date;
QString subject;
QString body;
QString bodyPlain;
bool sent, received, read, downloaded;
QString rawMail;
int mimeType; //1 = Mime 1.0
int serverId;
int internalId;
int fromAccountId;
QString contentType; //0 = text
QString contentAttribute; //0 = plain, 1 = html
EnclosureList files;
uint size;
void addEnclosure(Enclosure *e)
{
files.append(e);
}
};
struct MailAccount
{
QString accountName;
QString name;
QString emailAddress;
QString popUserName;
QString popPasswd;
QString popServer;
QString smtpServer;
bool synchronize;
+ int syncLimit;
int lastServerMailCount;
int id;
};
const int ErrUnknownResponse = 1001;
const int ErrLoginFailed = 1002;
const int ErrCancel = 1003;
class EmailHandler : public QObject
{
Q_OBJECT
public:
EmailHandler();
void setAccount(MailAccount account);
void sendMail(QList<Email> *mailList);
void getMail();
void getMailHeaders();
void getMailByList(MailList *mailList);
bool parse(QString in, QString lineShift, Email *mail);
bool getEnclosure(Enclosure *ePtr);
int parse64base(char *src, char *dest);
int encodeMime(Email *mail);
int encodeFile(QString fileName, QString *toBody);
void encode64base(char *src, QString *dest, int len);
void cancel();
signals:
void mailSent();
void smtpError(int);
void popError(int);
void mailArrived(const Email &, bool);
void updatePopStatus(const QString &);
void updateSmtpStatus(const QString &);
void mailTransfered(int);
void mailboxSize(int);
void currentMailSize(int);
void downloadedSize(int);
public slots:
void messageArrived(const QString &, int id, uint size, bool complete);
private:
MailAccount mailAccount;
SmtpClient *smtpClient;
PopClient *popClient;
bool headers;
};
#endif
diff --git a/noncore/net/mailit/emaillistitem.cpp b/noncore/net/mailit/emaillistitem.cpp
index d47b0b7..a325766 100644
--- a/noncore/net/mailit/emaillistitem.cpp
+++ b/noncore/net/mailit/emaillistitem.cpp
@@ -1,92 +1,97 @@
/**********************************************************************
** 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 <qstring.h>
+#include <qpe/resource.h>
#include "emaillistitem.h"
EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox)
: QListViewItem(parent)
{
QString temp;
mail = mailIn;
if (inbox) {
setText(0, mail.from);
} else {
QStringList::Iterator it = mail.recipients.begin();
temp = *it;
if (mail.recipients.count() > 1)
temp += "...";
setText(0, temp);
}
setText(1, mail.subject);
+ if (mailIn.files.count()>0)
+ {
+ setPixmap(0, Resource::loadPixmap("mailit/attach"));
+ }
selected = FALSE;
}
Email* EmailListItem::getMail()
{
return &mail;
}
void EmailListItem::setMail(Email newMail)
{
mail = newMail;
repaint();
}
void EmailListItem::setItemSelected(bool enable)
{
selected = enable;
setSelected(enable);
repaint();
}
bool EmailListItem::isItemSelected()
{
return selected;
}
void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg,
int column, int width, int alignment )
{
QColorGroup _cg( cg );
QColor c = _cg.text();
if ( (! mail.read) && (mail.received) )
_cg.setColor( QColorGroup::Text, Qt::blue);
if (!mail.downloaded)
_cg.setColor( QColorGroup::Text, Qt::red);
/* if (selected) {
_cg.setColor(QColorGroup::Base, Qt::blue);
_cg.setColor(QColorGroup::Text, Qt::yellow);
if (isSelected()) {
_cg.setColor(QColorGroup::HighlightedText, Qt::yellow);
} else {
_cg.setColor(QColorGroup::Highlight, Qt::blue);
}
}
*/
QListViewItem::paintCell( p, _cg, column, width, alignment );
_cg.setColor( QColorGroup::Text, c );
}
diff --git a/noncore/net/mailit/mailit.pro b/noncore/net/mailit/mailit.pro
index a404884..b262f9a 100644
--- a/noncore/net/mailit/mailit.pro
+++ b/noncore/net/mailit/mailit.pro
@@ -1,43 +1,60 @@
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 -lopie
# -lssl
MOC_DIR=qpeobj
OBJECTS_DIR=qpeobj
DESTDIR=$(OPIEDIR)/bin
+TRANSLATIONS = ../../../i18n/de/mailit.ts \
+ ../../../i18n/da/mailit.ts \
+ ../../../i18n/xx/mailit.ts \
+ ../../../i18n/en/mailit.ts \
+ ../../../i18n/es/mailit.ts \
+ ../../../i18n/fr/mailit.ts \
+ ../../../i18n/hu/mailit.ts \
+ ../../../i18n/ja/mailit.ts \
+ ../../../i18n/ko/mailit.ts \
+ ../../../i18n/no/mailit.ts \
+ ../../../i18n/pl/mailit.ts \
+ ../../../i18n/pt/mailit.ts \
+ ../../../i18n/pt_BR/mailit.ts \
+ ../../../i18n/sl/mailit.ts \
+ ../../../i18n/zh_CN/mailit.ts \
+ ../../../i18n/zh_TW/mailit.ts
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp
index 2011ecf..a5e7147 100644
--- a/noncore/net/mailit/readmail.cpp
+++ b/noncore/net/mailit/readmail.cpp
@@ -1,120 +1,120 @@
/**********************************************************************
** 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"
+#include <qpe/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( "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( "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( "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) {
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp
index a45cfd2..38a2596 100644
--- a/noncore/net/mailit/writemail.cpp
+++ b/noncore/net/mailit/writemail.cpp
@@ -1,118 +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 <qmessagebox.h>
#include "writemail.h"
-#include "resource.h"
+#include <qpe/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->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("Name");
addressView->addColumn("EMail");
addressView->setAllColumnsShowFocus(TRUE);
diff --git a/noncore/unsupported/mailit/addatt.cpp b/noncore/unsupported/mailit/addatt.cpp
index c8be865..d268f1f 100644
--- a/noncore/unsupported/mailit/addatt.cpp
+++ b/noncore/unsupported/mailit/addatt.cpp
@@ -1,162 +1,162 @@
/**********************************************************************
** 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 <qpe/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, 1,1 );
QHBox *buttons=new QHBox(this);
/*fileCategoryButton = new QPushButton(this);*/
- attatchButton = new QPushButton("Attatch ->", buttons);
- removeButton = new QPushButton("Remove", buttons);
+ attatchButton = new QPushButton(tr("Attatch..."), buttons);
+ removeButton = new QPushButton(tr("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);*/
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()
{
OFileDialog ofs("Attachments",this,0,0,"/root/Documents");
ofs.showMaximized();
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();
}
diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp
index 43e3830..9fe558a 100644
--- a/noncore/unsupported/mailit/addresslist.cpp
+++ b/noncore/unsupported/mailit/addresslist.cpp
@@ -1,181 +1,161 @@
/**********************************************************************
** 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)
+AddressList::AddressList()
{
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()
{
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;
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();*/
}
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/addresslist.h b/noncore/unsupported/mailit/addresslist.h
index e87d6f1..99cef9a 100644
--- a/noncore/unsupported/mailit/addresslist.h
+++ b/noncore/unsupported/mailit/addresslist.h
@@ -1,59 +1,58 @@
/**********************************************************************
** 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 ADDRESSLIST_H
#define ADDRESSLIST_H
#include <qobject.h>
#include <qlist.h>
struct Contact
{
QString email;
QString name;
};
class AddressList : public QObject
{
Q_OBJECT
public:
- AddressList(QString file);
+ AddressList();
~AddressList();
void addContact(QString email, QString name);
bool containsEmail(QString email);
bool containsName(QString name);
QString getNameByEmail(QString email);
QString getEmailByName(QString name);
QList<Contact>* getContactList();
- void write();
private:
int getEmailRef(QString email);
int getNameRef(QString name);
QString getRightString(QString in);
void read();
private:
QList<Contact> addresses;
QString filename;
bool dirty;
};
#endif
diff --git a/noncore/unsupported/mailit/editaccount.cpp b/noncore/unsupported/mailit/editaccount.cpp
index c4f95ea..c0afbb2 100644
--- a/noncore/unsupported/mailit/editaccount.cpp
+++ b/noncore/unsupported/mailit/editaccount.cpp
@@ -1,120 +1,133 @@
/**********************************************************************
** 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 <qhbox.h>
#include "editaccount.h"
EditAccount::EditAccount( QWidget* parent, const char* name, WFlags fl )
: QDialog(parent, name, fl)
{
setCaption( tr("Edit Account") );
init();
popPasswInput->setEchoMode(QLineEdit::Password);
}
void EditAccount::setAccount(MailAccount *in, bool newOne)
{
account = in;
if (newOne) {
accountNameInput->setText("");
nameInput->setText("");
emailInput->setText("");
popUserInput->setText("");
popPasswInput->setText("");
popServerInput->setText("");
smtpServerInput->setText("");
syncCheckBox->setChecked(TRUE);
+ syncLimitInput->setValue(2);
setCaption( tr("Create new Account") );
} else {
accountNameInput->setText(account->accountName);
nameInput->setText(account->name);
emailInput->setText(account->emailAddress);
popUserInput->setText(account->popUserName);
popPasswInput->setText(account->popPasswd);
popServerInput->setText(account->popServer);
smtpServerInput->setText(account->smtpServer);
syncCheckBox->setChecked(account->synchronize);
+ syncLimitInput->setValue(account->syncLimit/1000);
}
}
void EditAccount::init()
{
grid = new QGridLayout(this);
grid->setSpacing( 6 );
grid->setMargin( 11 );
accountNameInputLabel = new QLabel(tr("Account name"), this);
grid->addWidget( accountNameInputLabel, 0, 0 );
accountNameInput = new QLineEdit( this, "account nameInput" );
grid->addWidget( accountNameInput, 0, 1 );
nameInputLabel = new QLabel(tr("Your name"), this);
grid->addWidget( nameInputLabel, 1, 0 );
nameInput = new QLineEdit( this, "nameInput" );
grid->addWidget( nameInput, 1, 1 );
- emailInputLabel = new QLabel("Email", this);
+ emailInputLabel = new QLabel(tr("Email"), this);
grid->addWidget(emailInputLabel, 2, 0 );
emailInput = new QLineEdit( this, "emailInput" );
grid->addWidget( emailInput, 2, 1 );
- popUserInputLabel = new QLabel("POP username", this);
+ popUserInputLabel = new QLabel(tr("POP username"), this);
grid->addWidget( popUserInputLabel, 3, 0 );
popUserInput = new QLineEdit( this, "popUserInput" );
grid->addWidget( popUserInput, 3, 1 );
- popPasswInputLabel = new QLabel( "POP password", this);
+ popPasswInputLabel = new QLabel( tr("POP password"), this);
grid->addWidget( popPasswInputLabel, 4, 0 );
popPasswInput = new QLineEdit( this, "popPasswInput" );
grid->addWidget( popPasswInput, 4, 1 );
- popServerInputLabel = new QLabel("POP server", this);
+ popServerInputLabel = new QLabel(tr("POP server"), this);
grid->addWidget( popServerInputLabel, 5, 0 );
popServerInput = new QLineEdit( this, "popServerInput" );
grid->addWidget( popServerInput, 5, 1 );
- smtpServerInputLabel = new QLabel("SMTP server", this );
+ smtpServerInputLabel = new QLabel(tr("SMTP server"), this );
grid->addWidget( smtpServerInputLabel, 6, 0 );
smtpServerInput = new QLineEdit( this, "smtpServerInput" );
grid->addWidget( smtpServerInput, 6, 1 );
- syncCheckBox = new QCheckBox( tr( "Synchronize with server" ), this);
+ QHBox* syncBox=new QHBox(this);
+ grid->addWidget( syncBox, 7, 1 );
+
+ syncCheckBox = new QCheckBox( tr( "Synchronize" ), this);
syncCheckBox->setChecked( TRUE );
- grid->addMultiCellWidget( syncCheckBox, 7, 7, 0, 1 );
+ grid->addWidget( syncCheckBox,7,0);
+
+ syncLimitInputLabel = new QLabel(tr("Mail Size (k)"), syncBox);
+ //syncBox->addWidget( syncLimitInputLabel);
+ syncLimitInput = new QSpinBox( syncBox, "syncSize" );
+ //syncBox->addWidget(syncLimitInput);
+
}
void EditAccount::accept()
{
account->accountName = accountNameInput->text();
account->name = nameInput->text();
account->emailAddress = emailInput->text();
account->popUserName = popUserInput->text();
account->popPasswd = popPasswInput->text();
account->popServer = popServerInput->text();
account->smtpServer = smtpServerInput->text();
account->synchronize = syncCheckBox->isChecked();
+ account->syncLimit = syncLimitInput->value()*1000; //Display in kB
QDialog::accept();
}
void EditAccount::reject()
{
}
diff --git a/noncore/unsupported/mailit/editaccount.h b/noncore/unsupported/mailit/editaccount.h
index 7a90e50..1e15047 100644
--- a/noncore/unsupported/mailit/editaccount.h
+++ b/noncore/unsupported/mailit/editaccount.h
@@ -1,66 +1,69 @@
/**********************************************************************
** 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 EDITACCOUNT_H
#define EDITACCOUNT_H
#include <qdialog.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qlayout.h>
+#include <qspinbox.h>
#include "emailhandler.h"
class EditAccount : public QDialog
{
Q_OBJECT
public:
EditAccount( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
void setAccount(MailAccount *in, bool newOne = TRUE);
void init();
public slots:
void accept();
void reject();
private:
MailAccount thisAccount, *account;
QLabel *accountNameInputLabel;
QLabel *nameInputLabel;
QLabel *emailInputLabel;
QLabel *popUserInputLabel;
QLabel *popPasswInputLabel;
QLabel *popServerInputLabel;
QLabel *smtpServerInputLabel;
+ QLabel *syncLimitInputLabel;
QLineEdit *accountNameInput;
QLineEdit *nameInput;
QLineEdit *emailInput;
QLineEdit *popUserInput;
QLineEdit *popPasswInput;
QLineEdit *popServerInput;
QLineEdit *smtpServerInput;
+ QSpinBox *syncLimitInput;
QCheckBox *syncCheckBox;
QGridLayout *grid;
};
#endif
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index 2943986..6612541 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -1,140 +1,140 @@
/**********************************************************************
** 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 <qpe/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");
+ addressList = new AddressList();
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);
@@ -578,237 +578,245 @@ void EmailClient::readMail()
void EmailClient::saveMail(QString fileName, QListView *view)
{
QFile f(fileName);
Email *mail;
if (! f.open(IO_WriteOnly) ) {
qWarning("could not open file");
return;
}
item = (EmailListItem *) view->firstChild();
qDebug (QString("Write : ") );
QTextStream t(&f);
while (item != NULL) {
mail = item->getMail();
qDebug(mail->rawMail);
qDebug(mail->recipients.first());
t << mail->rawMail;
mailconf->setGroup(mail->id);
mailconf->writeEntry("mailread", mail->read);
item = (EmailListItem *) item->nextSibling();
}
f.close();
}
//paths for mailit, is settings, inbox, enclosures
QString EmailClient::getPath(bool enclosurePath)
{
QString basePath = "qtmail";
QString enclosures = "enclosures";
QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath);
if ( !dir.exists() )
dir.mkdir( dir.path() );
if (enclosurePath) {
dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures);
if ( !dir.exists() )
dir.mkdir( dir.path() );
return (dir.path() + "/");
}
return (dir.path() + "/");
}
void EmailClient::readSettings()
{
TextParser *p;
QString s;
int pos, accountPos, y;
QFile f( getPath(FALSE) + "settings.txt");
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
s = t.read();
f.close();
p = new TextParser(s, "\n");
accountPos = 0;
while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) {
accountPos++;
if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 )
account.accountName = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1)
account.name = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1)
account.emailAddress = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1)
account.popUserName = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1)
account.popPasswd = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1)
account.popServer = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1)
account.smtpServer = p->getString(& ++pos, 'z', TRUE);
if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) {
s = p->getString(& ++pos, 'z', TRUE);
account.id = s.toInt();
}
account.lastServerMailCount = 0;
account.synchronize = FALSE;
if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) {
if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") {
account.synchronize = TRUE;
if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) {
s = p->getString(& ++pos, 'z', TRUE);
account.lastServerMailCount = s.toInt();
}
}
}
+
+ if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) {
+ account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt();
+ }
+
+
accountList.append(&account);
}
delete p;
}
mailconf->setGroup("mailitglobal");
if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) {
mailIdCount = y;
}
if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) {
accountIdCount = y;
}
}
void EmailClient::saveSettings()
{
QString temp;
QFile f( getPath(FALSE) + "settings.txt");
MailAccount *accountPtr;
if (! f.open(IO_WriteOnly) ) {
qWarning("could not save settings file");
return;
}
QTextStream t(&f);
t << "#Settings for QPE Mailit program\n";
for (accountPtr = accountList.first(); accountPtr != 0;
accountPtr = accountList.next()) {
t << "accountStart;\n";
t << "AccountName: " + accountPtr->accountName + "\n";
t << "Name: " + accountPtr->name + "\n";
t << "Email: " + accountPtr->emailAddress + "\n";
t << "POPUser: " + accountPtr->popUserName + "\n";
t << "POPPAssword: " + accountPtr->popPasswd + "\n";
t << "POPServer: " + accountPtr->popServer + "\n";
t << "SMTPServer: " + accountPtr->smtpServer + "\n";
t << "AccountId: " << accountPtr->id << "\n";
if (accountPtr->synchronize) {
t << "Synchronize: Yes\n";
t << "LastServerMailCount: ";
t << accountPtr->lastServerMailCount << "\n";
} else {
t << "Synchronize: No\n";
}
+ t << "SyncLimit: ";
+ t << accountPtr->syncLimit << "\n";
t << "accountEnd;\n";
}
f.close();
mailconf->setGroup("mailitglobal");
mailconf->writeEntry("mailidcount", mailIdCount);
mailconf->writeEntry("accountidcount", accountIdCount);
}
void EmailClient::selectAccount(int id)
{
if (accountList.count() > 0) {
currentAccount = accountList.at(id);
emit newCaption("Mailit - " + currentAccount->accountName);
getNewMail();
} else {
emit newCaption("Mailit ! No account defined");
}
}
void EmailClient::editAccount(int id)
{
MailAccount *newAccount;
editAccountView = new EditAccount(this, "account", TRUE);
if (id == newAccountId) { //new account
newAccount = new MailAccount;
editAccountView->setAccount(newAccount);
} else {
newAccount = accountList.at(id);
editAccountView->setAccount(newAccount, FALSE);
}
editAccountView->showMaximized();
editAccountView->exec();
if (editAccountView->result() == QDialog::Accepted) {
if (id == newAccountId) {
newAccount->id = accountIdCount;
accountIdCount++;
accountList.append(newAccount);
updateAccounts();
} else {
updateAccounts();
}
}
delete editAccountView;
}
void EmailClient::deleteAccount(int id)
{
MailAccount *newAccount;
QString message;
newAccount = accountList.at(id);
message = "Delete account:\n" + newAccount->accountName;
switch( QMessageBox::warning( this, "Mailit", message,
"Yes", "No", 0, 0, 1 ) ) {
case 0: accountList.remove(id);
updateAccounts();
break;
case 1:
break;
}
}
void EmailClient::updateAccounts()
{
MailAccount *accountPtr;
//rebuild menus, clear all first
editAccountMenu->clear();
selectAccountMenu->clear();
deleteAccountMenu->clear();
newAccountId = editAccountMenu->insertItem("New", this,
SLOT(editAccount(int)) );
editAccountMenu->insertSeparator();
idCount = 0;
for (accountPtr = accountList.first(); accountPtr != 0;
accountPtr = accountList.next()) {
editAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(editAccount(int)), 0, idCount);
selectAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(selectAccount(int)), 0, idCount);
deleteAccountMenu->insertItem(accountPtr->accountName,
this, SLOT(deleteAccount(int)), 0, idCount);
idCount++;
}
}
void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox)
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index 1be16d4..9c1c814 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -25,286 +25,295 @@
#include "emailhandler.h"
#include <qpe/applnk.h>
#include <qpe/filemanager.h>
QCollection::Item EnclosureList::newItem(QCollection::Item d)
{
return dupl( (Enclosure *) d);
}
Enclosure* EnclosureList::dupl(Enclosure *in)
{
ac = new Enclosure(*in);
return ac;
}
EmailHandler::EmailHandler()
{
smtpClient = new SmtpClient();
popClient = new PopClient();
connect(smtpClient, SIGNAL(errorOccurred(int)), this,
SIGNAL(smtpError(int)) );
connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) );
connect(smtpClient, SIGNAL(updateStatus(const QString &)), this,
SIGNAL(updateSmtpStatus(const QString &)) );
connect(popClient, SIGNAL(errorOccurred(int)), this,
SIGNAL(popError(int)) );
connect(popClient, SIGNAL(newMessage(const QString &, int, uint, bool)),
this, SLOT(messageArrived(const QString &, int, uint, bool)) );
connect(popClient, SIGNAL(updateStatus(const QString &)), this,
SIGNAL(updatePopStatus(const QString &)) );
connect(popClient, SIGNAL(mailTransfered(int)), this,
SIGNAL(mailTransfered(int)) );
//relaying size information
connect(popClient, SIGNAL(currentMailSize(int)),
this, SIGNAL(currentMailSize(int)) );
connect(popClient, SIGNAL(downloadedSize(int)),
this, SIGNAL(downloadedSize(int)) );
}
void EmailHandler::sendMail(QList<Email> *mailList)
{
Email *currentMail;
QString temp;
QString userName = mailAccount.name;
userName += " <" + mailAccount.emailAddress + ">";
for (currentMail = mailList->first(); currentMail != 0;
currentMail = mailList->next()) {
if (encodeMime(currentMail) == 0) {
smtpClient->addMail(userName, currentMail->subject,
currentMail->recipients, currentMail->rawMail);
} else { //error
temp = tr("Could not locate all files in \nmail with subject: ") +
currentMail->subject;
temp += tr("\nMail has NOT been sent");
QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n"));
}
}
smtpClient->newConnection(mailAccount.smtpServer, 25);
}
void EmailHandler::setAccount(MailAccount account)
{
mailAccount = account;
}
void EmailHandler::getMail()
{
popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
if (mailAccount.synchronize) {
popClient->setSynchronize(mailAccount.lastServerMailCount);
} else {
popClient->removeSynchronize();
}
headers = FALSE;
popClient->headersOnly(headers, 0);
popClient->newConnection(mailAccount.popServer, 110);
}
void EmailHandler::getMailHeaders()
{
popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
if (mailAccount.synchronize) {
popClient->setSynchronize(mailAccount.lastServerMailCount);
} else {
popClient->removeSynchronize();
}
headers = TRUE;
- popClient->headersOnly(headers, 2000); //less than 2000, download all
+ popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all
popClient->newConnection(mailAccount.popServer, 110);
}
void EmailHandler::getMailByList(MailList *mailList)
{
if (mailList->count() == 0) { //should not occur though
emit mailTransfered(0);
return;
}
headers = FALSE;
popClient->headersOnly(FALSE, 0);
popClient->newConnection(mailAccount.popServer, 110);
popClient->setSelectedMails(mailList);
}
void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete)
{
Email mail;
mail.rawMail = message;
mail.serverId = id;
mail.size = size;
mail.downloaded = complete;
emit mailArrived(mail, FALSE);
}
bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
{
QString temp, boundary;
int pos;
QString delimiter, header, body, mimeHeader, mimeBody;
QString content, contentType, contentAttribute, id, encoding;
QString fileName, storedName;
int enclosureId = 0;
mail->rawMail = in;
mail->received = TRUE;
mail->files.setAutoDelete(TRUE);
temp = lineShift + "." + lineShift;
if (in.right(temp.length()) != temp) {
qWarning(in.right(temp.length()));
qWarning(" . added at end of email as separator");
mail->rawMail += temp;
}
delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
pos = in.find(delimiter, 0, FALSE);
header = in.left(pos);
body = in.right(in.length() - pos - delimiter.length());
if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
body.truncate(body.length()-2);
TextParser p(header, lineShift);
if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
pos++;
if (p.separatorAt(pos) == ' ') {
mail->from = p.getString(&pos, '<', false);
mail->from = mail->from.stripWhiteSpace();
if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
mail->from = mail->from.left(mail->from.length() - 1);
mail->from = mail->from.right(mail->from.length() - 1);
}
pos++;
mail->fromMail = p.getString(&pos, '>', false);
} else {
if ((p.separatorAt(pos) == '<')
|| (p.separatorAt(pos) == ' ')) //No name.. nasty
pos++;
pos++;
mail->fromMail = p.getString(&pos, 'z', TRUE);
if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
mail->fromMail.truncate(mail->fromMail.length() - 1);
mail->from=mail->fromMail;
}
}
+
+ //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To:
+ if (pos = p.find("TO",':', pos, TRUE) != -1)
+ {
+ pos++;
+ mail->recipients.append (p.getString(&pos, 'z', TRUE) );
+ }
+
+
+
if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
pos++;
mail->subject = p.getString(&pos, 'z', TRUE);
}
if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
pos++;
mail->date = p.getString(&pos, 'z', true);
}
- if ((pos = p.find("TO",':', 0, TRUE)) != -1) {
- pos++;
- mail->recipients.append (p.getString(&pos, 'z', TRUE) );
- }
+
+
+
if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
pos++;
if ( (p.wordAt(pos).upper() == "ID") &&
(p.separatorAt(pos) == ':') ) {
id = p.getString(&pos, 'z', TRUE);
mail->id = id;
}
}
pos = 0;
while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) {
pos++;
if ( (p.wordAt(pos).upper() == "VERSION") &&
(p.separatorAt(pos) == ':') ) {
pos++;
if (p.getString(&pos, 'z', true) == "1.0") {
mail->mimeType = 1;
}
}
}
if (mail->mimeType == 1) {
boundary = "";
if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) {
pos++;
boundary = p.getString(&pos, 'z', true);
if (boundary[0] == '"') {
boundary = boundary.left(boundary.length() - 1); //strip "
boundary = boundary.right(boundary.length() - 1); //strip "
}
boundary = "--" + boundary; //create boundary field
}
if (boundary == "") { //fooled by Mime-Version
mail->body = body;
mail->bodyPlain = body;
return mail;
}
while (body.length() > 0) {
pos = body.find(boundary, 0, FALSE);
pos = body.find(delimiter, pos, FALSE);
mimeHeader = body.left(pos);
mimeBody = body.right(body.length() - pos - delimiter.length());
TextParser bp(mimeHeader, lineShift);
contentType = "";
contentAttribute = "";
fileName = "";
if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) {
pos++;
if ( (bp.wordAt(pos).upper() == "TYPE") &&
(bp.separatorAt(pos) == ':') ) {
contentType = bp.nextWord().upper();
if (bp.nextSeparator() == '/')
contentAttribute = bp.nextWord().upper();
content = contentType + "/" + contentAttribute;
}
if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) {
pos++;
encoding = bp.getString(&pos, 'z', TRUE);
}
if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) {
pos++;
fileName = bp.getString(&pos, 'z', TRUE);
fileName = fileName.right(fileName.length() - 1);
fileName = fileName.left(fileName.length() - 1);
}
}
pos = mimeBody.find(boundary, 0, FALSE);
if (pos == -1) //should not occur, malformed mail
pos = mimeBody.length();
body = mimeBody.right(mimeBody.length() - pos);
mimeBody = mimeBody.left(pos);
if (fileName != "") { //attatchments of some type, audio, image etc.
Enclosure e;
e.id = enclosureId;
e.originalName = fileName;
e.contentType = contentType;
e.contentAttribute = contentAttribute;
e.encoding = encoding;
e.body = mimeBody;
e.saved = FALSE;
mail->addEnclosure(&e);
enclosureId++;
} else if (contentType == "TEXT") {
if (contentAttribute == "PLAIN") {
mail->body = mimeBody;
mail->bodyPlain = mimeBody;
}
diff --git a/noncore/unsupported/mailit/emailhandler.h b/noncore/unsupported/mailit/emailhandler.h
index 17c4414..e47fd9a 100644
--- a/noncore/unsupported/mailit/emailhandler.h
+++ b/noncore/unsupported/mailit/emailhandler.h
@@ -1,147 +1,148 @@
/**********************************************************************
** 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 EmailHandler_H
#define EmailHandler_H
#include <qobject.h>
#include <qstring.h>
#include <qdatetime.h>
#include <qlist.h>
#include <qstringlist.h>
#include <qfile.h>
#include <qstringlist.h>
#include <qcollection.h>
#include "smtpclient.h"
#include "popclient.h"
#include "textparser.h"
#include "maillist.h"
struct Enclosure
{
int id;
QString originalName;
QString name;
QString path;
QString contentType;
QString contentAttribute;
QString encoding;
QString body; //might use to much mem. check!!
bool saved, installed;
};
class EnclosureList : public QList<Enclosure>
{
public:
Item newItem(Item d);
private:
Enclosure* dupl(Enclosure *in);
Enclosure *ac;
};
struct Email
{
QString id;
QString from;
QString fromMail;
QStringList recipients;
QStringList carbonCopies;
QString date;
QString subject;
QString body;
QString bodyPlain;
bool sent, received, read, downloaded;
QString rawMail;
int mimeType; //1 = Mime 1.0
int serverId;
int internalId;
int fromAccountId;
QString contentType; //0 = text
QString contentAttribute; //0 = plain, 1 = html
EnclosureList files;
uint size;
void addEnclosure(Enclosure *e)
{
files.append(e);
}
};
struct MailAccount
{
QString accountName;
QString name;
QString emailAddress;
QString popUserName;
QString popPasswd;
QString popServer;
QString smtpServer;
bool synchronize;
+ int syncLimit;
int lastServerMailCount;
int id;
};
const int ErrUnknownResponse = 1001;
const int ErrLoginFailed = 1002;
const int ErrCancel = 1003;
class EmailHandler : public QObject
{
Q_OBJECT
public:
EmailHandler();
void setAccount(MailAccount account);
void sendMail(QList<Email> *mailList);
void getMail();
void getMailHeaders();
void getMailByList(MailList *mailList);
bool parse(QString in, QString lineShift, Email *mail);
bool getEnclosure(Enclosure *ePtr);
int parse64base(char *src, char *dest);
int encodeMime(Email *mail);
int encodeFile(QString fileName, QString *toBody);
void encode64base(char *src, QString *dest, int len);
void cancel();
signals:
void mailSent();
void smtpError(int);
void popError(int);
void mailArrived(const Email &, bool);
void updatePopStatus(const QString &);
void updateSmtpStatus(const QString &);
void mailTransfered(int);
void mailboxSize(int);
void currentMailSize(int);
void downloadedSize(int);
public slots:
void messageArrived(const QString &, int id, uint size, bool complete);
private:
MailAccount mailAccount;
SmtpClient *smtpClient;
PopClient *popClient;
bool headers;
};
#endif
diff --git a/noncore/unsupported/mailit/emaillistitem.cpp b/noncore/unsupported/mailit/emaillistitem.cpp
index d47b0b7..a325766 100644
--- a/noncore/unsupported/mailit/emaillistitem.cpp
+++ b/noncore/unsupported/mailit/emaillistitem.cpp
@@ -1,92 +1,97 @@
/**********************************************************************
** 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 <qstring.h>
+#include <qpe/resource.h>
#include "emaillistitem.h"
EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox)
: QListViewItem(parent)
{
QString temp;
mail = mailIn;
if (inbox) {
setText(0, mail.from);
} else {
QStringList::Iterator it = mail.recipients.begin();
temp = *it;
if (mail.recipients.count() > 1)
temp += "...";
setText(0, temp);
}
setText(1, mail.subject);
+ if (mailIn.files.count()>0)
+ {
+ setPixmap(0, Resource::loadPixmap("mailit/attach"));
+ }
selected = FALSE;
}
Email* EmailListItem::getMail()
{
return &mail;
}
void EmailListItem::setMail(Email newMail)
{
mail = newMail;
repaint();
}
void EmailListItem::setItemSelected(bool enable)
{
selected = enable;
setSelected(enable);
repaint();
}
bool EmailListItem::isItemSelected()
{
return selected;
}
void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg,
int column, int width, int alignment )
{
QColorGroup _cg( cg );
QColor c = _cg.text();
if ( (! mail.read) && (mail.received) )
_cg.setColor( QColorGroup::Text, Qt::blue);
if (!mail.downloaded)
_cg.setColor( QColorGroup::Text, Qt::red);
/* if (selected) {
_cg.setColor(QColorGroup::Base, Qt::blue);
_cg.setColor(QColorGroup::Text, Qt::yellow);
if (isSelected()) {
_cg.setColor(QColorGroup::HighlightedText, Qt::yellow);
} else {
_cg.setColor(QColorGroup::Highlight, Qt::blue);
}
}
*/
QListViewItem::paintCell( p, _cg, column, width, alignment );
_cg.setColor( QColorGroup::Text, c );
}
diff --git a/noncore/unsupported/mailit/mailit.pro b/noncore/unsupported/mailit/mailit.pro
index a404884..b262f9a 100644
--- a/noncore/unsupported/mailit/mailit.pro
+++ b/noncore/unsupported/mailit/mailit.pro
@@ -1,43 +1,60 @@
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 -lopie
# -lssl
MOC_DIR=qpeobj
OBJECTS_DIR=qpeobj
DESTDIR=$(OPIEDIR)/bin
+TRANSLATIONS = ../../../i18n/de/mailit.ts \
+ ../../../i18n/da/mailit.ts \
+ ../../../i18n/xx/mailit.ts \
+ ../../../i18n/en/mailit.ts \
+ ../../../i18n/es/mailit.ts \
+ ../../../i18n/fr/mailit.ts \
+ ../../../i18n/hu/mailit.ts \
+ ../../../i18n/ja/mailit.ts \
+ ../../../i18n/ko/mailit.ts \
+ ../../../i18n/no/mailit.ts \
+ ../../../i18n/pl/mailit.ts \
+ ../../../i18n/pt/mailit.ts \
+ ../../../i18n/pt_BR/mailit.ts \
+ ../../../i18n/sl/mailit.ts \
+ ../../../i18n/zh_CN/mailit.ts \
+ ../../../i18n/zh_TW/mailit.ts
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/unsupported/mailit/readmail.cpp b/noncore/unsupported/mailit/readmail.cpp
index 2011ecf..a5e7147 100644
--- a/noncore/unsupported/mailit/readmail.cpp
+++ b/noncore/unsupported/mailit/readmail.cpp
@@ -1,120 +1,120 @@
/**********************************************************************
** 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"
+#include <qpe/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( "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( "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( "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) {
diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp
index a45cfd2..38a2596 100644
--- a/noncore/unsupported/mailit/writemail.cpp
+++ b/noncore/unsupported/mailit/writemail.cpp
@@ -1,118 +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 <qmessagebox.h>
#include "writemail.h"
-#include "resource.h"
+#include <qpe/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->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("Name");
addressView->addColumn("EMail");
addressView->setAllColumnsShowFocus(TRUE);