summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mailit
authorkergoth <kergoth>2003-08-09 17:00:23 (UTC)
committer kergoth <kergoth>2003-08-09 17:00:23 (UTC)
commitc33d5ec60361238e50a4a9d6e0eec03e396dce60 (patch) (side-by-side diff)
tree31c0c85dc4262044db90c7918014bc45265ef420 /noncore/unsupported/mailit
parent78c296d534589835801fb6374ac9d43d44b2b1c9 (diff)
downloadopie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.zip
opie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.tar.gz
opie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.tar.bz2
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/unsupported/mailit') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mailit/config.in2
-rw-r--r--noncore/unsupported/mailit/popclient.cpp57
-rw-r--r--noncore/unsupported/mailit/resource.cpp136
-rw-r--r--noncore/unsupported/mailit/resource.h80
-rw-r--r--noncore/unsupported/mailit/smtpclient.cpp6
-rw-r--r--noncore/unsupported/mailit/viewatt.cpp24
6 files changed, 45 insertions, 260 deletions
diff --git a/noncore/unsupported/mailit/config.in b/noncore/unsupported/mailit/config.in
index 2b56b5f..142b840 100644
--- a/noncore/unsupported/mailit/config.in
+++ b/noncore/unsupported/mailit/config.in
@@ -1,4 +1,4 @@
config MAILIT
- boolean "mailit"
+ boolean "opie-mailit (a simple POP3 email client)"
default "n"
depends ( LIBQPE || LIBQPE-X11 )
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index 5da3bcb..1df6b2b 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -26,24 +26,25 @@ extern "C" {
}
#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;
+ mailList = 0;
preview = FALSE;
}
PopClient::~PopClient()
{
delete socket;
@@ -53,27 +54,27 @@ PopClient::~PopClient()
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(tr("DNS lookup"));
}
void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
{
popUserName = popUser;
popPassword = popPasswd;
-}
+}
void PopClient::setSynchronize(int lastCount)
{
synchronize = TRUE;
lastSync = lastCount;
}
@@ -120,86 +121,86 @@ void PopClient::incomingData()
int start, end;
// char *md5Digest;
char md5Digest[16];
// if ( !socket->canReadLine() )
// return;
-
+
response = socket->readLine();
-
+
switch(status) {
//logging in
case Init: {
#ifdef APOP_TEST
start = response.find('<',0);
end = response.find('>', start);
if( start >= 0 && end > start )
{
timeStamp = response.mid( start , end - start + 1);
md5Source = timeStamp + popPassword;
-
+
md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
{
printf("%x", md5Digest[j]);
}
- printf("\n");
+ printf("\n");
// qDebug(md5Digest);
*stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
// qDebug("%s", stream);
status = Stat;
}
else
#endif
{
timeStamp = "";
*stream << "USER " << popUserName << "\r\n";
status = Pass;
}
-
+
break;
}
-
+
case Pass: {
*stream << "PASS " << popPassword << "\r\n";
status = Stat;
-
+
break;
}
//ask for number of messages
case Stat: {
if (response[0] == '+') {
*stream << "STAT" << "\r\n";
- status = Mcnt;
+ status = Mcnt;
} else errorHandlingWithMsg(ErrLoginFailed, response);
break;
}
//get count of messages, eg "+OK 4 900.." -> int 4
case Mcnt: {
if (response[0] == '+') {
temp = response.replace(0, 4, "");
int x = temp.find(" ", 0);
temp.truncate((uint) x);
newMessages = temp.toInt();
messageCount = 1;
status = List;
-
+
if (synchronize) {
//messages deleted from server, reload all
if (newMessages < lastSync)
lastSync = 0;
messageCount = 1;
}
-
- if (selected) {
+
+ if (selected && mailList ) {
int *ptr = mailList->first();
if (ptr != 0) {
newMessages++; //to ensure no early jumpout
messageCount = *ptr;
- } else newMessages = 0;
+ } else newMessages = 0;
}
} else errorHandlingWithMsg(ErrUnknownResponse, response);
}
//Read message number x, count upwards to messageCount
case List: {
@@ -221,43 +222,43 @@ void PopClient::incomingData()
}
break;
} else {
emit updateStatus(tr("No new Messages"));
status = Quit;
}
- }
+ }
//get size of message, eg "500 characters in message.." -> int 500
case Size: {
if (status != Quit) { //because of idiotic switch
if (response[0] == '+') {
temp = response.replace(0, 4, "");
int x = temp.find(" ", 0);
temp = temp.right(temp.length() - ((uint) x + 1) );
mailSize = temp.toInt();
emit currentMailSize(mailSize);
-
+
status = Retr;
} else {
//qWarning(response);
errorHandlingWithMsg(ErrUnknownResponse, response);
}
}
- }
+ }
//Read message number x, count upwards to messageCount
case Retr: {
if (status != Quit) {
- if ((selected)||(mailSize <= headerLimit))
+ if ((selected)||(mailSize <= headerLimit))
{
*stream << "RETR " << messageCount << "\r\n";
} else { //only header
*stream << "TOP " << messageCount << " 0\r\n";
}
messageCount++;
status = Ignore;
break;
- } }
+ } }
case Ignore: {
if (status != Quit) { //because of idiotic switch
if (response[0] == '+') {
message = "";
status = Read;
if (!socket->canReadLine()) //sync. problems
@@ -283,29 +284,29 @@ void PopClient::incomingData()
if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
{
emit newMessage(message, messageCount-1, mailSize, TRUE);
} else { //incomplete mail downloaded
emit newMessage(message, messageCount-1, mailSize, FALSE);
}
-
+
if ((messageCount > newMessages)||(selected)) //last message ?
{
status = Quit;
if (selected) { //grab next from queue
newMessages--;
status = Quit;
}
}
- else
+ else
{
*stream << "LIST " << messageCount << "\r\n";
status = Size;
temp2.setNum(newMessages - lastSync);
temp.setNum(messageCount - lastSync);
emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
-
+
break;
}
}
}
if (status != Quit)
break;
@@ -317,13 +318,13 @@ void PopClient::incomingData()
if (newM > 0) {
temp.setNum(newM);
emit updateStatus(temp + tr(" new messages"));
} else {
emit updateStatus(tr("No new messages"));
}
-
+
socket->close();
receiving = FALSE;
emit mailTransfered(newM);
break;
}
}
diff --git a/noncore/unsupported/mailit/resource.cpp b/noncore/unsupported/mailit/resource.cpp
deleted file mode 100644
index dc19880..0000000
--- a/noncore/unsupported/mailit/resource.cpp
+++ b/dev/null
@@ -1,136 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia 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 "qpeapplication.h"
-#include "resource.h"
-#include <qdir.h>
-#include <qfile.h>
-#include <qregexp.h>
-#include <qpixmapcache.h>
-#include <qpainter.h>
-
-#include "inlinepics_p.h"
-
-/*!
- \class Resource resource.h
- \brief The Resource class provides access to named resources.
-
- The resources may be provided from files or other sources.
-*/
-
-/*!
- \fn Resource::Resource()
- \internal
-*/
-
-/*!
- Returns the QPixmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QPixmap Resource::loadPixmap( const QString &pix )
-{
- QPixmap pm;
- QString key="QPE_"+pix;
- if ( !QPixmapCache::find(key,pm) ) {
- pm.convertFromImage(loadImage(pix));
- QPixmapCache::insert(key,pm);
- }
- return pm;
-}
-
-/*!
- Returns the QBitmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QBitmap Resource::loadBitmap( const QString &pix )
-{
- QBitmap bm;
- bm = loadPixmap(pix);
- return bm;
-}
-
-/*!
- Returns the filename of a pixmap named \a pix. You should avoid including
- any filename type extension (eg. .png, .xpm).
-
- Normally you will use loadPixmap() rather than this function.
-*/
-QString Resource::findPixmap( const QString &pix )
-{
- QString picsPath = QPEApplication::qpeDir() + "pics/";
-
- if ( QFile( picsPath + pix + ".png").exists() )
- return picsPath + pix + ".png";
- else if ( QFile( picsPath + pix + ".xpm").exists() )
- return picsPath + pix + ".xpm";
- else if ( QFile( picsPath + pix ).exists() )
- return picsPath + pix;
-
- //qDebug("Cannot find pixmap: %s", pix.latin1());
- return QString();
-}
-
-/*!
- Returns a sound file for a sound named \a name.
- You should avoid including any filename type extension (eg. .wav, .au, .mp3).
-*/
-QString Resource::findSound( const QString &name )
-{
- QString picsPath = QPEApplication::qpeDir() + "sounds/";
-
- QString result;
- if ( QFile( (result = picsPath + name + ".wav") ).exists() )
- return result;
-
- return QString();
-}
-
-/*!
- Returns a list of all sound names.
-*/
-QStringList Resource::allSounds()
-{
- QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" );
- QStringList entries = resourcedir.entryList();
- QStringList result;
- for (QStringList::Iterator i=entries.begin(); i != entries.end(); ++i)
- result.append((*i).replace(QRegExp("\\.wav"),""));
- return result;
-}
-
-/*!
- Returns the QImage named \a name. You should avoid including
- any filename type extension (eg. .png, .xpm).
-*/
-QImage Resource::loadImage( const QString &name)
-{
- QImage img = qembed_findImage(name.latin1());
- if ( img.isNull() )
- return QImage(findPixmap(name));
- return img;
-}
-
-/*!
- \fn QIconSet Resource::loadIconSet( const QString &name )
-
- Returns a QIconSet for the pixmap named \a name. A disabled icon is
- generated that conforms to the Qtopia look & feel. You should avoid
- including any filename type extension (eg. .png, .xpm).
-*/
diff --git a/noncore/unsupported/mailit/resource.h b/noncore/unsupported/mailit/resource.h
deleted file mode 100644
index 982c58a..0000000
--- a/noncore/unsupported/mailit/resource.h
+++ b/dev/null
@@ -1,80 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia 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 PIXMAPLOADER_H
-#define PIXMAPLOADER_H
-
-#include <qimage.h>
-#include <qbitmap.h>
-#include <qiconset.h>
-#include <qstringlist.h>
-
-class Resource
-{
-public:
- Resource() {}
-
- static QImage loadImage( const QString &name);
-
- static QPixmap loadPixmap( const QString &name );
- static QBitmap loadBitmap( const QString &name );
- static QString findPixmap( const QString &name );
-
- static QIconSet loadIconSet( const QString &name );
-
- static QString findSound( const QString &name );
- static QStringList allSounds();
-};
-
-// Inline for compatibility with SHARP ROMs
-inline QIconSet Resource::loadIconSet( const QString &pix )
-{
- QImage img = loadImage( pix );
- QPixmap pm;
- pm.convertFromImage( img );
- QIconSet is( pm );
- QIconSet::Size size = pm.width() <= 22 ? QIconSet::Small : QIconSet::Large;
-
- QPixmap dpm = loadPixmap( pix + "_disabled" );
-
-#ifndef QT_NO_DEPTH_32 // have alpha-blended pixmaps
- if ( dpm.isNull() ) {
- QImage dimg( img.width(), img.height(), 32 );
- for ( int y = 0; y < img.height(); y++ ) {
- for ( int x = 0; x < img.width(); x++ ) {
- QRgb p = img.pixel( x, y );
- uint a = (p & 0xff000000) / 3;
- p = (p & 0x00ffffff) | (a & 0xff000000);
- dimg.setPixel( x, y, p );
- }
- }
-
- dimg.setAlphaBuffer( TRUE );
- dpm.convertFromImage( dimg );
- }
-#endif
-
- if ( !dpm.isNull() )
- is.setPixmap( dpm, size, QIconSet::Disabled );
-
- return is;
-}
-
-
-#endif
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp
index 5b5ef52..51ca50b 100644
--- a/noncore/unsupported/mailit/smtpclient.cpp
+++ b/noncore/unsupported/mailit/smtpclient.cpp
@@ -101,33 +101,33 @@ void SmtpClient::incomingData()
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case From: {
if (response[0] == '2') {
qDebug(mailPtr->from);
- *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n";
+ *stream << "MAIL FROM: " << mailPtr->from << "\r\n";
status = Recv;
} else errorHandlingWithMsg(ErrUnknownResponse, response );
break;
}
case Recv: {
if (response[0] == '2') {
it = mailPtr->to.begin();
if (it == NULL) {
errorHandlingWithMsg(ErrUnknownResponse,response);
}
- *stream << "RCPT TO: <" << *it << ">\r\n";
+ *stream << "RCPT TO: " << *it << "\r\n";
status = MRcv;
} else errorHandlingWithMsg(ErrUnknownResponse,response);
break;
}
case MRcv: {
if (response[0] == '2') {
it++;
if ( it != mailPtr->to.end() ) {
- *stream << "RCPT TO: <" << *it << ">\r\n";
+ *stream << "RCPT TO: " << *it << "\r\n";
break;
} else {
status = Data;
}
} else errorHandlingWithMsg(ErrUnknownResponse,response);
}
diff --git a/noncore/unsupported/mailit/viewatt.cpp b/noncore/unsupported/mailit/viewatt.cpp
index 293e137..3515ba5 100644
--- a/noncore/unsupported/mailit/viewatt.cpp
+++ b/noncore/unsupported/mailit/viewatt.cpp
@@ -14,13 +14,13 @@
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
-#include "resource.h"
+#include <qpe/resource.h>
#include "viewatt.h"
#include <qwhatsthis.h>
#include <qpe/applnk.h>
#include <qpe/mimetype.h>
ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
@@ -30,49 +30,49 @@ ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
setToolBarsMovable( FALSE );
bar = new QToolBar(this);
installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
-
+
listView = new QListView(this, "AttView");
listView->addColumn( tr("Attatchment") );
listView->addColumn( tr("Type") );
listView->addColumn( tr("Installed") );
setCentralWidget(listView);
QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
}
void ViewAtt::update(Email *mailIn, bool inbox)
{
QListViewItem *item;
Enclosure *ePtr;
-
-
+
+
listView->clear();
if (inbox) {
bar->clear();
installButton->addTo( bar );
bar->show();
} else {
bar->hide();
}
-
+
mail = mailIn;
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
-
+
QString isInstalled = tr("No");
if (ePtr->installed)
isInstalled = tr("Yes");
item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
-
+
const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
-
+
MimeType mt(mtypeDef);
-
+
item->setPixmap(0, mt.pixmap());
/*
if (ePtr->contentType == "TEXT") {
actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
actions->addTo(bar);
@@ -93,27 +93,27 @@ void ViewAtt::update(Email *mailIn, bool inbox)
void ViewAtt::install()
{
Enclosure *ePtr, *selPtr;
QListViewItem *item;
QString filename;
DocLnk d;
-
+
item = listView->selectedItem();
if (item != NULL) {
filename = item->text(0);
selPtr = NULL;
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
if (ePtr->originalName == filename)
selPtr = ePtr;
}
-
+
if (selPtr == NULL) {
qWarning("Internal error, file is not installed to documents");
return;
}
-
+
d.setName(selPtr->originalName);
d.setFile(selPtr->path + selPtr->name);
d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
d.writeLink();
selPtr->installed = TRUE;
item->setText(2, tr("Yes"));