summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-05-24 01:20:33 (UTC)
committer llornkcor <llornkcor>2003-05-24 01:20:33 (UTC)
commit62d2ddfb5cd77e2637cdf7fe16d76aac04975984 (patch) (side-by-side diff)
tree2157d57bab2d6e491226f5bc8468a4c2527e1456
parent0c4b5288ccd4bcd1668816a0c4e12ce0a76b4e6e (diff)
downloadopie-62d2ddfb5cd77e2637cdf7fe16d76aac04975984.zip
opie-62d2ddfb5cd77e2637cdf7fe16d76aac04975984.tar.gz
opie-62d2ddfb5cd77e2637cdf7fe16d76aac04975984.tar.bz2
QString to const QString
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mailit/addresslist.cpp16
-rw-r--r--noncore/net/mailit/addresslist.h16
-rw-r--r--noncore/net/mailit/emailclient.cpp7
-rw-r--r--noncore/net/mailit/emailclient.h2
-rw-r--r--noncore/net/mailit/emailhandler.cpp4
-rw-r--r--noncore/net/mailit/emailhandler.h4
-rw-r--r--noncore/net/mailit/emaillistitem.cpp0
-rw-r--r--noncore/net/mailit/popclient.cpp4
-rw-r--r--noncore/net/mailit/popclient.h4
-rw-r--r--noncore/net/mailit/smtpclient.cpp4
-rw-r--r--noncore/net/mailit/smtpclient.h4
-rw-r--r--noncore/net/mailit/textparser.cpp14
-rw-r--r--noncore/net/mailit/textparser.h6
-rw-r--r--noncore/unsupported/mailit/addresslist.cpp16
-rw-r--r--noncore/unsupported/mailit/addresslist.h16
-rw-r--r--noncore/unsupported/mailit/emailclient.cpp7
-rw-r--r--noncore/unsupported/mailit/emailclient.h2
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp4
-rw-r--r--noncore/unsupported/mailit/emailhandler.h4
-rw-r--r--noncore/unsupported/mailit/emaillistitem.cpp0
-rw-r--r--noncore/unsupported/mailit/popclient.cpp4
-rw-r--r--noncore/unsupported/mailit/popclient.h4
-rw-r--r--noncore/unsupported/mailit/smtpclient.cpp4
-rw-r--r--noncore/unsupported/mailit/smtpclient.h4
-rw-r--r--noncore/unsupported/mailit/textparser.cpp14
-rw-r--r--noncore/unsupported/mailit/textparser.h6
26 files changed, 86 insertions, 84 deletions
diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp
index 7d60ebf..18d14bc 100644
--- a/noncore/net/mailit/addresslist.cpp
+++ b/noncore/net/mailit/addresslist.cpp
@@ -7,155 +7,155 @@
** 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()
{
addresses.setAutoDelete(TRUE);
read();
dirty = FALSE;
}
AddressList::~AddressList()
{
addresses.clear();
}
-void AddressList::addContact(QString email, QString name)
+void AddressList::addContact(const QString &email, const 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)
+bool AddressList::containsEmail(const QString &email)
{
return ( getEmailRef(email) != -1 );
}
-bool AddressList::containsName(QString name)
+bool AddressList::containsName(const QString &name)
{
return ( getNameRef(name) != -1 );
}
-QString AddressList::getNameByEmail(QString email)
+QString AddressList::getNameByEmail(const QString &email)
{
int pos = getEmailRef(email);
if (pos != -1) {
Contact *ptr = addresses.at(pos);
return ptr->name;
}
return NULL;
}
-QString AddressList::getEmailByName(QString name)
+QString AddressList::getEmailByName(const 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 AddressList::getEmailRef(const 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 AddressList::getNameRef(const 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;
QString lineEmail, lineName, email, name;
OContactAccess m_contactdb("mailit");
OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
//OContact* oc;(*it).defaultEmail()
for ( it = m_list.begin(); it != m_list.end(); ++it )
{
//oc=(OContact*) it;
if ((*it).defaultEmail().length()!=0)
addContact((*it).defaultEmail(),(*it).fileAs());
}
/*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 AddressList::getRightString(const QString &in)
{
QString out = "";
int pos = in.find('=');
if (pos != -1) {
out = in.mid(pos+1).stripWhiteSpace();
}
return out;
}
diff --git a/noncore/net/mailit/addresslist.h b/noncore/net/mailit/addresslist.h
index 99cef9a..b46d467 100644
--- a/noncore/net/mailit/addresslist.h
+++ b/noncore/net/mailit/addresslist.h
@@ -7,52 +7,52 @@
** 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();
~AddressList();
- void addContact(QString email, QString name);
- bool containsEmail(QString email);
- bool containsName(QString name);
- QString getNameByEmail(QString email);
- QString getEmailByName(QString name);
+ void addContact(const QString &email, const QString &name);
+ bool containsEmail(const QString &email);
+ bool containsName(const QString &name);
+ QString getNameByEmail(const QString &email);
+ QString getEmailByName(const QString &name);
QList<Contact>* getContactList();
private:
- int getEmailRef(QString email);
- int getNameRef(QString name);
- QString getRightString(QString in);
+ int getEmailRef(const QString &email);
+ int getNameRef(const QString &name);
+ QString getRightString(const QString &in);
void read();
private:
QList<Contact> addresses;
QString filename;
bool dirty;
};
#endif
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
index b039cc4..2102ba7 100644
--- a/noncore/net/mailit/emailclient.cpp
+++ b/noncore/net/mailit/emailclient.cpp
@@ -437,66 +437,67 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
} else {
ePtr->saved = FALSE;
mailconf->writeEntry("saved_" + stringId, ePtr->saved);
}
} else {
ePtr->saved = mailconf->readBoolEntry("saved_" + stringId);
ePtr->installed = mailconf->readBoolEntry("installed_" + stringId);
if (ePtr->saved) {
ePtr->name = mailconf->readEntry("filename_" + stringId);
ePtr->path = mailconf->readEntry("path_" + stringId);
}
}
}
bool found=false;
if (!fromDisk)
{
Email *mailPtr;
item = (EmailListItem *) inboxView->firstChild();
while ((item != NULL)&&(!found))
{
mailPtr = item->getMail();
if (mailPtr->id == newMail.id) {
item->setMail(newMail);
emit mailUpdated(item->getMail());
found = true;
}
item = (EmailListItem *) item->nextSibling();
}
}
- if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE);
-
+ if ((!found)||(fromDisk)) {
+ item = new EmailListItem(inboxView, newMail, TRUE);
+ }
if (item->getMail()->files.count()>0)
{
item->setPixmap(0, Resource::loadPixmap("mailit/attach"));
}
/*if (!newMail.downloaded)
mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
mailboxView->setCurrentTab(0);
}
void EmailClient::allMailArrived(int count)
{
// not previewing means all mailtransfer has been done
/*if (!previewingMail) {*/
if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
emit newCaption("Mailit - " + currentAccount->accountName);
getNewMail();
return;
} else {
allAccounts = FALSE;
receiving = FALSE;
getMailButton->setEnabled(TRUE);
cancelButton->setEnabled(FALSE);
selectAccountMenu->setEnabled(TRUE);
status1Label->setText("Idle");
progressBar->reset();
return;
}
//}
@@ -613,65 +614,65 @@ void EmailClient::readMail()
stop = s.length() - del.length();
mail.rawMail = s.mid(start, stop + del.length() - start );
start = stop + del.length();
mailArrived(mail, TRUE);
}
}
QFile fo(getPath(FALSE) + "outbox.txt");
if ( fo.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &fo ); // use a text stream
s = t.read();
fo.close();
start = 0;
del = "\n.\n";
while ((uint) start < s.length()) {
stop = s.find(del, start);
if (stop == -1)
stop = s.length() - del.length();
mail.rawMail = s.mid(start, stop + del.length() - start );
start = stop + del.length();
emailHandler->parse(mail.rawMail, lineShift, &mail);
mail.sent = false;
mail.received = false;
enqueMail(mail);
}
}
}
-void EmailClient::saveMail(QString fileName, QListView *view)
+void EmailClient::saveMail(const QString &fileName, QListView *view)
{
QFile f(fileName);
Email *mail;
if (! f.open(IO_WriteOnly) ) {
qWarning("could not open file");
return;
}
item = (EmailListItem *) view->firstChild();
QTextStream t(&f);
while (item != NULL) {
mail = item->getMail();
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() );
diff --git a/noncore/net/mailit/emailclient.h b/noncore/net/mailit/emailclient.h
index 994fec5..c98cfce 100644
--- a/noncore/net/mailit/emailclient.h
+++ b/noncore/net/mailit/emailclient.h
@@ -77,65 +77,65 @@ protected:
signals:
void composeRequested();
void viewEmail(QListView *, Email *);
void mailUpdated(Email *);
void newCaption(const QString &);
void replyRequested(Email&, bool&);
void forwardRequested(Email&);
void removeItem(EmailListItem*, bool&);
/*void reply(Email&);
void replyAll(Email&);
void remove(Email&);
void forward(Email&);*/
public slots:
void compose();
void cancel();
void enqueMail(const Email &mail);
void setMailAccount();
void sendQuedMail();
void mailSent();
void deleteItem();
void getNewMail();
void getAllNewMail();
void smtpError(int code);
void popError(int code);
void inboxItemSelected();
void outboxItemSelected();
void inboxItemPressed();
void inboxItemReleased();
void mailArrived(const Email &mail, bool fromDisk);
void allMailArrived(int);
- void saveMail(QString fileName, QListView *view);
+ void saveMail(const QString &fileName, QListView *view);
void selectAccount(int);
void editAccount(int);
void updateAccounts();
void deleteAccount(int);
void deleteMail(EmailListItem *mailItem, bool &inbox);
void setTotalSize(int);
void setMailSize(int);
void setDownloadedSize(int);
void moveMailFront(Email *mailPtr);
void download(Email*);
/* void reply();
void replyAll();
void forward();
void remove();*/
private slots:
void receive(const QCString&, const QByteArray&);
private:
void init();
void initStatusBar(QWidget*);
void readMail();
QString getPath(bool enclosurePath);
void readSettings();
void saveSettings();
Email* getCurrentMail();
int timerID;
Config *mailconf;
int newAccountId, idCount, mailIdCount;
int accountIdCount;
AccountList accountList;
AddressList *addressList;
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
index 62fa64f..59ccd90 100644
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/noncore/net/mailit/emailhandler.cpp
@@ -119,65 +119,65 @@ void EmailHandler::getMailHeaders()
popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all
qDebug("Initiating connection");
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->setAccount(mailAccount.popUserName,mailAccount.popPasswd);
popClient->setSelectedMails(mailList);
popClient->newConnection(mailAccount.popServer, 110);
}
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)
+bool EmailHandler::parse(const QString &in, const 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) {
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);
@@ -481,65 +481,65 @@ int EmailHandler::encodeMime(Email *mail)
// This specification of contentType is temporary
contentType = "";
if (fileType == "Picture") {
contentType = "image/x-image";
} else if (fileType == "Document") {
contentType = "text/plain";
} else if (fileType == "Sound") {
contentType = "audio/x-wav";
} else if (fileType == "Movie") {
contentType = "video/mpeg";
} else {
contentType = "application/octet-stream";
}
newBody += "\r\n\r\n--" + boundary + "\r\n";
newBody += "Content-Type: " + contentType + "; name=\"" +
fi.fileName() + "\"\r\n";
newBody += "Content-Transfer-Encoding: base64\r\n";
newBody += "Content-Disposition: inline; filename=\"" +
fi.fileName() + "\"\r\n\r\n";
if (encodeFile(fileName, &newBody) == -1) //file not found?
return -1;
}
newBody += "\r\n\r\n--" + boundary + "--";
mail->rawMail = newBody;
return 0;
}
-int EmailHandler::encodeFile(QString fileName, QString *toBody)
+int EmailHandler::encodeFile(const QString &fileName, QString *toBody)
{
char *fileData;
char *dataPtr;
QString temp;
uint dataSize, count;
QFile f(fileName);
if (! f.open(IO_ReadOnly) ) {
qWarning("could not open file: " + fileName);
return -1;
}
QTextStream s(&f);
dataSize = f.size();
fileData = (char *) malloc(dataSize + 3);
s.readRawBytes(fileData, dataSize);
temp = "";
dataPtr = fileData;
count = 0;
while (dataSize > 0) {
if (dataSize < 3) {
encode64base(dataPtr, &temp, dataSize);
dataSize = 0;
} else {
encode64base(dataPtr, &temp, 3);
dataSize -= 3;
dataPtr += 3;
count += 4;
}
if (count > 72) {
count = 0;
temp += "\r\n";
diff --git a/noncore/net/mailit/emailhandler.h b/noncore/net/mailit/emailhandler.h
index 5b59f65..e4e7f46 100644
--- a/noncore/net/mailit/emailhandler.h
+++ b/noncore/net/mailit/emailhandler.h
@@ -88,63 +88,63 @@ struct Email
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);
MailAccount* getAccount(){return &mailAccount;}
void sendMail(QList<Email> *mailList);
void getMail();
void getMailHeaders();
void getMailByList(MailList *mailList);
- bool parse(QString in, QString lineShift, Email *mail);
+ bool parse(const QString &in, const QString &lineShift, Email *mail);
bool getEnclosure(Enclosure *ePtr);
int parse64base(char *src, char *dest);
int encodeMime(Email *mail);
- int encodeFile(QString fileName, QString *toBody);
+ int encodeFile(const 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 b925a1c..fc9f766 100644
--- a/noncore/net/mailit/emaillistitem.cpp
+++ b/noncore/net/mailit/emaillistitem.cpp
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp
index fedc4e2..dc0116d 100644
--- a/noncore/net/mailit/popclient.cpp
+++ b/noncore/net/mailit/popclient.cpp
@@ -21,81 +21,81 @@
#include "emailhandler.h"
//#define APOP_TEST
extern "C" {
#include "md5.h"
}
#include <qcstring.h>
PopClient::PopClient()
{
socket = new QSocket(this, "popClient");
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
stream = new QTextStream(socket);
receiving = FALSE;
synchronize = FALSE;
lastSync = 0;
headerLimit = 0;
preview = FALSE;
}
PopClient::~PopClient()
{
delete socket;
delete stream;
}
-void PopClient::newConnection(QString target, int port)
+void PopClient::newConnection(const QString &target, int port)
{
if (receiving) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
socket->connectToHost(target, port);
receiving = TRUE;
//selected = FALSE;
emit updateStatus("DNS lookup");
}
-void PopClient::setAccount(QString popUser, QString popPasswd)
+void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
{
popUserName = popUser;
popPassword = popPasswd;
}
void PopClient::setSynchronize(int lastCount)
{
synchronize = TRUE;
lastSync = lastCount;
}
void PopClient::removeSynchronize()
{
synchronize = FALSE;
lastSync = 0;
}
void PopClient::headersOnly(bool headers, int limit)
{
preview = headers;
headerLimit = limit;
}
void PopClient::setSelectedMails(MailList *list)
{
selected = TRUE;
mailList = list;
}
void PopClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
diff --git a/noncore/net/mailit/popclient.h b/noncore/net/mailit/popclient.h
index 10b71ab..c58bc48 100644
--- a/noncore/net/mailit/popclient.h
+++ b/noncore/net/mailit/popclient.h
@@ -6,66 +6,66 @@
** 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 PopClient_H
#define PopClient_H
#include <stdio.h>
#include <qsocket.h>
#include <qstring.h>
#include <qobject.h>
#include <qtextstream.h>
#include <qlist.h>
#include "maillist.h"
class PopClient: public QObject
{
Q_OBJECT
public:
PopClient();
~PopClient();
- void newConnection(QString target, int port);
- void setAccount(QString popUser, QString popPasswd);
+ void newConnection(const QString &target, int port);
+ void setAccount(const QString &popUser, const QString &popPasswd);
void setSynchronize(int lastCount);
void removeSynchronize();
void headersOnly(bool headers, int limit);
void setSelectedMails(MailList *list);
signals:
void newMessage(const QString &, int, uint, bool);
void errorOccurred(int status);
void updateStatus(const QString &);
void mailTransfered(int);
void mailboxSize(int);
void currentMailSize(int);
void downloadedSize(int);
public slots:
void errorHandling(int);
protected slots:
void connectionEstablished();
void incomingData();
private:
QSocket *socket;
QTextStream *stream;
enum transferStatus
{
Init, Pass, Stat, Mcnt, Read, List, Size, Retr, Acks,
Quit, Done, Ignore
};
int status, lastSync;
int messageCount, newMessages, mailSize, headerLimit;
bool receiving, synchronize, preview, selected;
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp
index 8a51a5b..2916f45 100644
--- a/noncore/net/mailit/smtpclient.cpp
+++ b/noncore/net/mailit/smtpclient.cpp
@@ -10,79 +10,79 @@
**
** 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 "smtpclient.h"
#include "emailhandler.h"
SmtpClient::SmtpClient()
{
socket = new QSocket(this, "smtpClient");
stream = new QTextStream(socket);
mailList.setAutoDelete(TRUE);
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
sending = FALSE;
}
SmtpClient::~SmtpClient()
{
delete socket;
delete stream;
}
-void SmtpClient::newConnection(QString target, int port)
+void SmtpClient::newConnection(const QString &target, int port)
{
if (sending) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
sending = TRUE;
socket->connectToHost(target, port);
emit updateStatus(tr("DNS lookup"));
}
-void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body)
+void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
{
RawEmail *mail = new RawEmail;
mail->from = from;
mail->subject = subject;
mail->to = to;
mail->body = body;
mailList.append(mail);
}
void SmtpClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
}
void SmtpClient::errorHandling(int status)
{
emit errorOccurred(status);
socket->close();
mailList.clear();
sending = FALSE;
}
void SmtpClient::incomingData()
{
QString response;
if (!socket->canReadLine())
return;
diff --git a/noncore/net/mailit/smtpclient.h b/noncore/net/mailit/smtpclient.h
index ca65af4..45c0703 100644
--- a/noncore/net/mailit/smtpclient.h
+++ b/noncore/net/mailit/smtpclient.h
@@ -14,62 +14,62 @@
** 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 SmtpClient_H
#define SmtpClient_H
//#include <stdio.h>
#include <qsocket.h>
#include <qstring.h>
#include <qobject.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <qlist.h>
struct RawEmail
{
QString from;
QString subject;
QStringList to;
QString body;
};
class SmtpClient: public QObject
{
Q_OBJECT
public:
SmtpClient();
~SmtpClient();
- void newConnection(QString target, int port);
- void addMail(QString from, QString subject, QStringList to, QString body);
+ void newConnection(const QString &target, int port);
+ void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body);
signals:
void errorOccurred(int);
void updateStatus(const QString &);
void mailSent();
public slots:
void errorHandling(int);
protected slots:
void connectionEstablished();
void incomingData();
private:
QSocket *socket;
QTextStream *stream;
enum transferStatus
{
Init, From, Recv, MRcv, Data, Body, Quit, Done
};
int status;
QList<RawEmail> mailList;
RawEmail *mailPtr;
bool sending;
QStringList::Iterator it;
};
#endif
diff --git a/noncore/net/mailit/textparser.cpp b/noncore/net/mailit/textparser.cpp
index 3fa5f6e..e5c9f7c 100644
--- a/noncore/net/mailit/textparser.cpp
+++ b/noncore/net/mailit/textparser.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 "textparser.h"
-TextParser::TextParser(QString in, QString lineBreak)
+TextParser::TextParser(const QString &in, const QString &lineBreak)
{
data = in;
lineSep = lineBreak;
init();
createSeparators();
split();
}
-TextParser::TextParser(QString in, QString lineBreak, QString sep)
+TextParser::TextParser(const QString &in, const QString &lineBreak, const QString &sep)
{
data = in;
lineSep = lineBreak;
init();
separators = sep;
split();
}
void TextParser::init()
{
lineCount = 0;
linePos = 0;
totalElmCount = 0;
separatorPos = -1; //not initialized
wordPos = -1; //not initialized
sepAtLine = 0;
sepAtPosElm = -1; //such that nextSep equals 0
wordAtLine = 0;
wordAtPosElm = -1; //such that nextWord equals 0
atLine = 0;
atPosElm = 0;
}
void TextParser::createSeparators()
{
separators = " @#,.:;<>*/(){}|'?-+=_";
}
/* Returns pos of given search criteria, -1 if not found */
-int TextParser::find(QString target, QChar sep, int pos, bool upperCase)
+int TextParser::find(const QString &target, QChar sep, int pos, bool upperCase)
{
t_splitElm parsstr;
- QString pString;
-
+ QString pString, pTarget;
+ pTarget = target;
int atLine = 0, atPosElm = 0;
getLineReference(pos,&atLine,&atPosElm);
for (int x = pos; x < totalElmCount; x++)
{
parsstr=splitDone[atLine].elm[atPosElm++];
if (upperCase)
{
pString=parsstr.str.upper();
- target=target.upper();
+ pTarget=pTarget.upper();
}
else
{
pString=parsstr.str;
}
- if ((pString == target) && (parsstr.separator == sep))
+ if ((pString == pTarget) && (parsstr.separator == sep))
{
return x;
}
if (atPosElm >= splitDone[atLine].elmCount)
{ //new Line
atLine++;
atPosElm = 0;
}
}
return -1;
}
int TextParser::elmCount()
{
return totalElmCount;
}
QChar TextParser::separatorAt(int pos)
{
if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1)
return QChar::null;
separatorPos = pos;
return splitDone[sepAtLine].elm[sepAtPosElm].separator;
}
QChar TextParser::nextSeparator()
{
sepAtPosElm++;
if (splitDone[sepAtLine].elmCount <= sepAtPosElm) {
sepAtLine++;
sepAtPosElm = 0;
diff --git a/noncore/net/mailit/textparser.h b/noncore/net/mailit/textparser.h
index c5e88a0..03bb6d5 100644
--- a/noncore/net/mailit/textparser.h
+++ b/noncore/net/mailit/textparser.h
@@ -20,66 +20,66 @@
#include <qobject.h>
#include <qstring.h>
#ifndef TEXTPARSER_H
#define TEXTPARSER_H
enum t_strType { Word, Number};
enum t_lineType {NewLine, LastLine};
const uint MAX_ELEMENTS = 200; //Should be dynamic
const uint MAX_LINES = 500; //Should be dynamic
struct t_splitElm
{
QChar separator;
int strType;
QString str;
};
struct t_splitLine
{
t_lineType lineType;
QString str; //a bit redundant...
t_splitElm elm[MAX_ELEMENTS];
int elmCount;
};
class TextParser: public QObject
{
Q_OBJECT
public:
- TextParser(QString in, QString lineBreak);
- TextParser(QString in, QString lineBreak, QString sep);
- int find(QString target, QChar sep, int pos, bool upperCase);
+ TextParser(const QString &in, const QString &lineBreak);
+ TextParser(const QString &in, const QString &lineBreak, const QString &sep);
+ int find(const QString &target, QChar sep, int pos, bool upperCase);
int elmCount();
QChar separatorAt(int pos);
QChar nextSeparator();
bool hasNextSeparator();
QString wordAt(int pos);
QString nextWord();
bool hasNextWord();
QString getString(int *pos, QChar stop, bool lineEnd);
QString getNextLine();
bool hasNextLine();
int endLinePos(int pos);
private:
void init();
void createSeparators();
t_splitLine nextLine();
void split();
t_splitLine splitLine(t_splitLine line);
bool isSeparator(QChar chr);
t_splitLine splitDone[MAX_LINES];
int getLineReference(int pos, int *line, int *inLinePos);
int lineCount, linePos, totalElmCount;
int separatorPos, wordPos;
QString data, separators, lineSep;
int sepAtLine, sepAtPosElm;
int wordAtLine, wordAtPosElm;
int atLine, atPosElm;
};
#endif
diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp
index 7d60ebf..18d14bc 100644
--- a/noncore/unsupported/mailit/addresslist.cpp
+++ b/noncore/unsupported/mailit/addresslist.cpp
@@ -7,155 +7,155 @@
** 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()
{
addresses.setAutoDelete(TRUE);
read();
dirty = FALSE;
}
AddressList::~AddressList()
{
addresses.clear();
}
-void AddressList::addContact(QString email, QString name)
+void AddressList::addContact(const QString &email, const 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)
+bool AddressList::containsEmail(const QString &email)
{
return ( getEmailRef(email) != -1 );
}
-bool AddressList::containsName(QString name)
+bool AddressList::containsName(const QString &name)
{
return ( getNameRef(name) != -1 );
}
-QString AddressList::getNameByEmail(QString email)
+QString AddressList::getNameByEmail(const QString &email)
{
int pos = getEmailRef(email);
if (pos != -1) {
Contact *ptr = addresses.at(pos);
return ptr->name;
}
return NULL;
}
-QString AddressList::getEmailByName(QString name)
+QString AddressList::getEmailByName(const 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 AddressList::getEmailRef(const 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 AddressList::getNameRef(const 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;
QString lineEmail, lineName, email, name;
OContactAccess m_contactdb("mailit");
OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
//OContact* oc;(*it).defaultEmail()
for ( it = m_list.begin(); it != m_list.end(); ++it )
{
//oc=(OContact*) it;
if ((*it).defaultEmail().length()!=0)
addContact((*it).defaultEmail(),(*it).fileAs());
}
/*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 AddressList::getRightString(const QString &in)
{
QString out = "";
int pos = in.find('=');
if (pos != -1) {
out = in.mid(pos+1).stripWhiteSpace();
}
return out;
}
diff --git a/noncore/unsupported/mailit/addresslist.h b/noncore/unsupported/mailit/addresslist.h
index 99cef9a..b46d467 100644
--- a/noncore/unsupported/mailit/addresslist.h
+++ b/noncore/unsupported/mailit/addresslist.h
@@ -7,52 +7,52 @@
** 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();
~AddressList();
- void addContact(QString email, QString name);
- bool containsEmail(QString email);
- bool containsName(QString name);
- QString getNameByEmail(QString email);
- QString getEmailByName(QString name);
+ void addContact(const QString &email, const QString &name);
+ bool containsEmail(const QString &email);
+ bool containsName(const QString &name);
+ QString getNameByEmail(const QString &email);
+ QString getEmailByName(const QString &name);
QList<Contact>* getContactList();
private:
- int getEmailRef(QString email);
- int getNameRef(QString name);
- QString getRightString(QString in);
+ int getEmailRef(const QString &email);
+ int getNameRef(const QString &name);
+ QString getRightString(const QString &in);
void read();
private:
QList<Contact> addresses;
QString filename;
bool dirty;
};
#endif
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp
index b039cc4..2102ba7 100644
--- a/noncore/unsupported/mailit/emailclient.cpp
+++ b/noncore/unsupported/mailit/emailclient.cpp
@@ -437,66 +437,67 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk)
} else {
ePtr->saved = FALSE;
mailconf->writeEntry("saved_" + stringId, ePtr->saved);
}
} else {
ePtr->saved = mailconf->readBoolEntry("saved_" + stringId);
ePtr->installed = mailconf->readBoolEntry("installed_" + stringId);
if (ePtr->saved) {
ePtr->name = mailconf->readEntry("filename_" + stringId);
ePtr->path = mailconf->readEntry("path_" + stringId);
}
}
}
bool found=false;
if (!fromDisk)
{
Email *mailPtr;
item = (EmailListItem *) inboxView->firstChild();
while ((item != NULL)&&(!found))
{
mailPtr = item->getMail();
if (mailPtr->id == newMail.id) {
item->setMail(newMail);
emit mailUpdated(item->getMail());
found = true;
}
item = (EmailListItem *) item->nextSibling();
}
}
- if ((!found)||(fromDisk)) item = new EmailListItem(inboxView, newMail, TRUE);
-
+ if ((!found)||(fromDisk)) {
+ item = new EmailListItem(inboxView, newMail, TRUE);
+ }
if (item->getMail()->files.count()>0)
{
item->setPixmap(0, Resource::loadPixmap("mailit/attach"));
}
/*if (!newMail.downloaded)
mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/
mailboxView->setCurrentTab(0);
}
void EmailClient::allMailArrived(int count)
{
// not previewing means all mailtransfer has been done
/*if (!previewingMail) {*/
if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
emit newCaption("Mailit - " + currentAccount->accountName);
getNewMail();
return;
} else {
allAccounts = FALSE;
receiving = FALSE;
getMailButton->setEnabled(TRUE);
cancelButton->setEnabled(FALSE);
selectAccountMenu->setEnabled(TRUE);
status1Label->setText("Idle");
progressBar->reset();
return;
}
//}
@@ -613,65 +614,65 @@ void EmailClient::readMail()
stop = s.length() - del.length();
mail.rawMail = s.mid(start, stop + del.length() - start );
start = stop + del.length();
mailArrived(mail, TRUE);
}
}
QFile fo(getPath(FALSE) + "outbox.txt");
if ( fo.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &fo ); // use a text stream
s = t.read();
fo.close();
start = 0;
del = "\n.\n";
while ((uint) start < s.length()) {
stop = s.find(del, start);
if (stop == -1)
stop = s.length() - del.length();
mail.rawMail = s.mid(start, stop + del.length() - start );
start = stop + del.length();
emailHandler->parse(mail.rawMail, lineShift, &mail);
mail.sent = false;
mail.received = false;
enqueMail(mail);
}
}
}
-void EmailClient::saveMail(QString fileName, QListView *view)
+void EmailClient::saveMail(const QString &fileName, QListView *view)
{
QFile f(fileName);
Email *mail;
if (! f.open(IO_WriteOnly) ) {
qWarning("could not open file");
return;
}
item = (EmailListItem *) view->firstChild();
QTextStream t(&f);
while (item != NULL) {
mail = item->getMail();
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() );
diff --git a/noncore/unsupported/mailit/emailclient.h b/noncore/unsupported/mailit/emailclient.h
index 994fec5..c98cfce 100644
--- a/noncore/unsupported/mailit/emailclient.h
+++ b/noncore/unsupported/mailit/emailclient.h
@@ -77,65 +77,65 @@ protected:
signals:
void composeRequested();
void viewEmail(QListView *, Email *);
void mailUpdated(Email *);
void newCaption(const QString &);
void replyRequested(Email&, bool&);
void forwardRequested(Email&);
void removeItem(EmailListItem*, bool&);
/*void reply(Email&);
void replyAll(Email&);
void remove(Email&);
void forward(Email&);*/
public slots:
void compose();
void cancel();
void enqueMail(const Email &mail);
void setMailAccount();
void sendQuedMail();
void mailSent();
void deleteItem();
void getNewMail();
void getAllNewMail();
void smtpError(int code);
void popError(int code);
void inboxItemSelected();
void outboxItemSelected();
void inboxItemPressed();
void inboxItemReleased();
void mailArrived(const Email &mail, bool fromDisk);
void allMailArrived(int);
- void saveMail(QString fileName, QListView *view);
+ void saveMail(const QString &fileName, QListView *view);
void selectAccount(int);
void editAccount(int);
void updateAccounts();
void deleteAccount(int);
void deleteMail(EmailListItem *mailItem, bool &inbox);
void setTotalSize(int);
void setMailSize(int);
void setDownloadedSize(int);
void moveMailFront(Email *mailPtr);
void download(Email*);
/* void reply();
void replyAll();
void forward();
void remove();*/
private slots:
void receive(const QCString&, const QByteArray&);
private:
void init();
void initStatusBar(QWidget*);
void readMail();
QString getPath(bool enclosurePath);
void readSettings();
void saveSettings();
Email* getCurrentMail();
int timerID;
Config *mailconf;
int newAccountId, idCount, mailIdCount;
int accountIdCount;
AccountList accountList;
AddressList *addressList;
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index 62fa64f..59ccd90 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -119,65 +119,65 @@ void EmailHandler::getMailHeaders()
popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all
qDebug("Initiating connection");
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->setAccount(mailAccount.popUserName,mailAccount.popPasswd);
popClient->setSelectedMails(mailList);
popClient->newConnection(mailAccount.popServer, 110);
}
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)
+bool EmailHandler::parse(const QString &in, const 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) {
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);
@@ -481,65 +481,65 @@ int EmailHandler::encodeMime(Email *mail)
// This specification of contentType is temporary
contentType = "";
if (fileType == "Picture") {
contentType = "image/x-image";
} else if (fileType == "Document") {
contentType = "text/plain";
} else if (fileType == "Sound") {
contentType = "audio/x-wav";
} else if (fileType == "Movie") {
contentType = "video/mpeg";
} else {
contentType = "application/octet-stream";
}
newBody += "\r\n\r\n--" + boundary + "\r\n";
newBody += "Content-Type: " + contentType + "; name=\"" +
fi.fileName() + "\"\r\n";
newBody += "Content-Transfer-Encoding: base64\r\n";
newBody += "Content-Disposition: inline; filename=\"" +
fi.fileName() + "\"\r\n\r\n";
if (encodeFile(fileName, &newBody) == -1) //file not found?
return -1;
}
newBody += "\r\n\r\n--" + boundary + "--";
mail->rawMail = newBody;
return 0;
}
-int EmailHandler::encodeFile(QString fileName, QString *toBody)
+int EmailHandler::encodeFile(const QString &fileName, QString *toBody)
{
char *fileData;
char *dataPtr;
QString temp;
uint dataSize, count;
QFile f(fileName);
if (! f.open(IO_ReadOnly) ) {
qWarning("could not open file: " + fileName);
return -1;
}
QTextStream s(&f);
dataSize = f.size();
fileData = (char *) malloc(dataSize + 3);
s.readRawBytes(fileData, dataSize);
temp = "";
dataPtr = fileData;
count = 0;
while (dataSize > 0) {
if (dataSize < 3) {
encode64base(dataPtr, &temp, dataSize);
dataSize = 0;
} else {
encode64base(dataPtr, &temp, 3);
dataSize -= 3;
dataPtr += 3;
count += 4;
}
if (count > 72) {
count = 0;
temp += "\r\n";
diff --git a/noncore/unsupported/mailit/emailhandler.h b/noncore/unsupported/mailit/emailhandler.h
index 5b59f65..e4e7f46 100644
--- a/noncore/unsupported/mailit/emailhandler.h
+++ b/noncore/unsupported/mailit/emailhandler.h
@@ -88,63 +88,63 @@ struct Email
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);
MailAccount* getAccount(){return &mailAccount;}
void sendMail(QList<Email> *mailList);
void getMail();
void getMailHeaders();
void getMailByList(MailList *mailList);
- bool parse(QString in, QString lineShift, Email *mail);
+ bool parse(const QString &in, const QString &lineShift, Email *mail);
bool getEnclosure(Enclosure *ePtr);
int parse64base(char *src, char *dest);
int encodeMime(Email *mail);
- int encodeFile(QString fileName, QString *toBody);
+ int encodeFile(const 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 b925a1c..fc9f766 100644
--- a/noncore/unsupported/mailit/emaillistitem.cpp
+++ b/noncore/unsupported/mailit/emaillistitem.cpp
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index fedc4e2..dc0116d 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -21,81 +21,81 @@
#include "emailhandler.h"
//#define APOP_TEST
extern "C" {
#include "md5.h"
}
#include <qcstring.h>
PopClient::PopClient()
{
socket = new QSocket(this, "popClient");
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
stream = new QTextStream(socket);
receiving = FALSE;
synchronize = FALSE;
lastSync = 0;
headerLimit = 0;
preview = FALSE;
}
PopClient::~PopClient()
{
delete socket;
delete stream;
}
-void PopClient::newConnection(QString target, int port)
+void PopClient::newConnection(const QString &target, int port)
{
if (receiving) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
socket->connectToHost(target, port);
receiving = TRUE;
//selected = FALSE;
emit updateStatus("DNS lookup");
}
-void PopClient::setAccount(QString popUser, QString popPasswd)
+void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
{
popUserName = popUser;
popPassword = popPasswd;
}
void PopClient::setSynchronize(int lastCount)
{
synchronize = TRUE;
lastSync = lastCount;
}
void PopClient::removeSynchronize()
{
synchronize = FALSE;
lastSync = 0;
}
void PopClient::headersOnly(bool headers, int limit)
{
preview = headers;
headerLimit = limit;
}
void PopClient::setSelectedMails(MailList *list)
{
selected = TRUE;
mailList = list;
}
void PopClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
diff --git a/noncore/unsupported/mailit/popclient.h b/noncore/unsupported/mailit/popclient.h
index 10b71ab..c58bc48 100644
--- a/noncore/unsupported/mailit/popclient.h
+++ b/noncore/unsupported/mailit/popclient.h
@@ -6,66 +6,66 @@
** 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 PopClient_H
#define PopClient_H
#include <stdio.h>
#include <qsocket.h>
#include <qstring.h>
#include <qobject.h>
#include <qtextstream.h>
#include <qlist.h>
#include "maillist.h"
class PopClient: public QObject
{
Q_OBJECT
public:
PopClient();
~PopClient();
- void newConnection(QString target, int port);
- void setAccount(QString popUser, QString popPasswd);
+ void newConnection(const QString &target, int port);
+ void setAccount(const QString &popUser, const QString &popPasswd);
void setSynchronize(int lastCount);
void removeSynchronize();
void headersOnly(bool headers, int limit);
void setSelectedMails(MailList *list);
signals:
void newMessage(const QString &, int, uint, bool);
void errorOccurred(int status);
void updateStatus(const QString &);
void mailTransfered(int);
void mailboxSize(int);
void currentMailSize(int);
void downloadedSize(int);
public slots:
void errorHandling(int);
protected slots:
void connectionEstablished();
void incomingData();
private:
QSocket *socket;
QTextStream *stream;
enum transferStatus
{
Init, Pass, Stat, Mcnt, Read, List, Size, Retr, Acks,
Quit, Done, Ignore
};
int status, lastSync;
int messageCount, newMessages, mailSize, headerLimit;
bool receiving, synchronize, preview, selected;
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp
index 8a51a5b..2916f45 100644
--- a/noncore/unsupported/mailit/smtpclient.cpp
+++ b/noncore/unsupported/mailit/smtpclient.cpp
@@ -10,79 +10,79 @@
**
** 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 "smtpclient.h"
#include "emailhandler.h"
SmtpClient::SmtpClient()
{
socket = new QSocket(this, "smtpClient");
stream = new QTextStream(socket);
mailList.setAutoDelete(TRUE);
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
sending = FALSE;
}
SmtpClient::~SmtpClient()
{
delete socket;
delete stream;
}
-void SmtpClient::newConnection(QString target, int port)
+void SmtpClient::newConnection(const QString &target, int port)
{
if (sending) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
sending = TRUE;
socket->connectToHost(target, port);
emit updateStatus(tr("DNS lookup"));
}
-void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body)
+void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
{
RawEmail *mail = new RawEmail;
mail->from = from;
mail->subject = subject;
mail->to = to;
mail->body = body;
mailList.append(mail);
}
void SmtpClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
}
void SmtpClient::errorHandling(int status)
{
emit errorOccurred(status);
socket->close();
mailList.clear();
sending = FALSE;
}
void SmtpClient::incomingData()
{
QString response;
if (!socket->canReadLine())
return;
diff --git a/noncore/unsupported/mailit/smtpclient.h b/noncore/unsupported/mailit/smtpclient.h
index ca65af4..45c0703 100644
--- a/noncore/unsupported/mailit/smtpclient.h
+++ b/noncore/unsupported/mailit/smtpclient.h
@@ -14,62 +14,62 @@
** 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 SmtpClient_H
#define SmtpClient_H
//#include <stdio.h>
#include <qsocket.h>
#include <qstring.h>
#include <qobject.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <qlist.h>
struct RawEmail
{
QString from;
QString subject;
QStringList to;
QString body;
};
class SmtpClient: public QObject
{
Q_OBJECT
public:
SmtpClient();
~SmtpClient();
- void newConnection(QString target, int port);
- void addMail(QString from, QString subject, QStringList to, QString body);
+ void newConnection(const QString &target, int port);
+ void addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body);
signals:
void errorOccurred(int);
void updateStatus(const QString &);
void mailSent();
public slots:
void errorHandling(int);
protected slots:
void connectionEstablished();
void incomingData();
private:
QSocket *socket;
QTextStream *stream;
enum transferStatus
{
Init, From, Recv, MRcv, Data, Body, Quit, Done
};
int status;
QList<RawEmail> mailList;
RawEmail *mailPtr;
bool sending;
QStringList::Iterator it;
};
#endif
diff --git a/noncore/unsupported/mailit/textparser.cpp b/noncore/unsupported/mailit/textparser.cpp
index 3fa5f6e..e5c9f7c 100644
--- a/noncore/unsupported/mailit/textparser.cpp
+++ b/noncore/unsupported/mailit/textparser.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 "textparser.h"
-TextParser::TextParser(QString in, QString lineBreak)
+TextParser::TextParser(const QString &in, const QString &lineBreak)
{
data = in;
lineSep = lineBreak;
init();
createSeparators();
split();
}
-TextParser::TextParser(QString in, QString lineBreak, QString sep)
+TextParser::TextParser(const QString &in, const QString &lineBreak, const QString &sep)
{
data = in;
lineSep = lineBreak;
init();
separators = sep;
split();
}
void TextParser::init()
{
lineCount = 0;
linePos = 0;
totalElmCount = 0;
separatorPos = -1; //not initialized
wordPos = -1; //not initialized
sepAtLine = 0;
sepAtPosElm = -1; //such that nextSep equals 0
wordAtLine = 0;
wordAtPosElm = -1; //such that nextWord equals 0
atLine = 0;
atPosElm = 0;
}
void TextParser::createSeparators()
{
separators = " @#,.:;<>*/(){}|'?-+=_";
}
/* Returns pos of given search criteria, -1 if not found */
-int TextParser::find(QString target, QChar sep, int pos, bool upperCase)
+int TextParser::find(const QString &target, QChar sep, int pos, bool upperCase)
{
t_splitElm parsstr;
- QString pString;
-
+ QString pString, pTarget;
+ pTarget = target;
int atLine = 0, atPosElm = 0;
getLineReference(pos,&atLine,&atPosElm);
for (int x = pos; x < totalElmCount; x++)
{
parsstr=splitDone[atLine].elm[atPosElm++];
if (upperCase)
{
pString=parsstr.str.upper();
- target=target.upper();
+ pTarget=pTarget.upper();
}
else
{
pString=parsstr.str;
}
- if ((pString == target) && (parsstr.separator == sep))
+ if ((pString == pTarget) && (parsstr.separator == sep))
{
return x;
}
if (atPosElm >= splitDone[atLine].elmCount)
{ //new Line
atLine++;
atPosElm = 0;
}
}
return -1;
}
int TextParser::elmCount()
{
return totalElmCount;
}
QChar TextParser::separatorAt(int pos)
{
if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1)
return QChar::null;
separatorPos = pos;
return splitDone[sepAtLine].elm[sepAtPosElm].separator;
}
QChar TextParser::nextSeparator()
{
sepAtPosElm++;
if (splitDone[sepAtLine].elmCount <= sepAtPosElm) {
sepAtLine++;
sepAtPosElm = 0;
diff --git a/noncore/unsupported/mailit/textparser.h b/noncore/unsupported/mailit/textparser.h
index c5e88a0..03bb6d5 100644
--- a/noncore/unsupported/mailit/textparser.h
+++ b/noncore/unsupported/mailit/textparser.h
@@ -20,66 +20,66 @@
#include <qobject.h>
#include <qstring.h>
#ifndef TEXTPARSER_H
#define TEXTPARSER_H
enum t_strType { Word, Number};
enum t_lineType {NewLine, LastLine};
const uint MAX_ELEMENTS = 200; //Should be dynamic
const uint MAX_LINES = 500; //Should be dynamic
struct t_splitElm
{
QChar separator;
int strType;
QString str;
};
struct t_splitLine
{
t_lineType lineType;
QString str; //a bit redundant...
t_splitElm elm[MAX_ELEMENTS];
int elmCount;
};
class TextParser: public QObject
{
Q_OBJECT
public:
- TextParser(QString in, QString lineBreak);
- TextParser(QString in, QString lineBreak, QString sep);
- int find(QString target, QChar sep, int pos, bool upperCase);
+ TextParser(const QString &in, const QString &lineBreak);
+ TextParser(const QString &in, const QString &lineBreak, const QString &sep);
+ int find(const QString &target, QChar sep, int pos, bool upperCase);
int elmCount();
QChar separatorAt(int pos);
QChar nextSeparator();
bool hasNextSeparator();
QString wordAt(int pos);
QString nextWord();
bool hasNextWord();
QString getString(int *pos, QChar stop, bool lineEnd);
QString getNextLine();
bool hasNextLine();
int endLinePos(int pos);
private:
void init();
void createSeparators();
t_splitLine nextLine();
void split();
t_splitLine splitLine(t_splitLine line);
bool isSeparator(QChar chr);
t_splitLine splitDone[MAX_LINES];
int getLineReference(int pos, int *line, int *inLinePos);
int lineCount, linePos, totalElmCount;
int separatorPos, wordPos;
QString data, separators, lineSep;
int sepAtLine, sepAtPosElm;
int wordAtLine, wordAtPosElm;
int atLine, atPosElm;
};
#endif