summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-08 14:04:54 (UTC)
committer alwin <alwin>2004-01-08 14:04:54 (UTC)
commitab6a32266c8fb625e782c601c9729af7f98904f6 (patch) (side-by-side diff)
tree1457c421109359bdaa50082f2640d33ac4d74cc2
parentb85bc4484bcc0a53557b4759c3e9e58dc9059138 (diff)
downloadopie-ab6a32266c8fb625e782c601c9729af7f98904f6.zip
opie-ab6a32266c8fb625e782c601c9729af7f98904f6.tar.gz
opie-ab6a32266c8fb625e782c601c9729af7f98904f6.tar.bz2
- store single message to another folder implemented
- cleaned code in mainwindow and opiemail.cpp
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp11
-rw-r--r--noncore/net/mail/accountview.h1
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp30
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
-rw-r--r--noncore/net/mail/mail.pro1
-rw-r--r--noncore/net/mail/mailistviewitem.cpp65
-rw-r--r--noncore/net/mail/mailistviewitem.h1
-rw-r--r--noncore/net/mail/mainwindow.cpp151
-rw-r--r--noncore/net/mail/mainwindow.h1
-rw-r--r--noncore/net/mail/opiemail.cpp119
-rw-r--r--noncore/net/mail/opiemail.h8
13 files changed, 263 insertions, 140 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index b7de7b9..9f4f358 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -827,65 +827,76 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList
setPixmap( 0, PIXMAP_MBOXFOLDER );
}
setText( 0, folder->getDisplayName() );
}
Folder*MBOXfolderItem::getFolder()
{
return folder;
}
void MBOXfolderItem::refresh(QList<RecMail>&target)
{
if (folder->may_select())
mbox->getWrapper()->listMessages( folder->getName(),target );
}
RecBody MBOXfolderItem::fetchBody(const RecMail&aMail)
{
return mbox->getWrapper()->fetchBody(aMail);
}
void MBOXfolderItem::deleteFolder()
{
int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
QObject::tr("Yes",contextName),
QObject::tr("No",contextName),QString::null,1,1);
qDebug("Auswahl: %i",yesno);
if (yesno == 0) {
if (mbox->getWrapper()->deleteMbox(folder)) {
QListView*v=listView();
MBOXviewItem * box = mbox;
/* be carefull - after that this object is destroyd so don't use
* any member of it after that call!!*/
mbox->refresh(true);
if (v) {
v->setSelected(box,true);
}
}
}
}
QPopupMenu * MBOXfolderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m) {
m->insertItem(QObject::tr("Delete all mails",contextName),0);
m->insertItem(QObject::tr("Delete folder",contextName),1);
+ m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
}
return m;
}
+void MBOXfolderItem::downloadMails()
+{
+ AccountView*bl = mbox->accountView();
+ if (!bl) return;
+ bl->downloadMails(folder,mbox->getWrapper());
+}
+
void MBOXfolderItem::contextMenuSelected(int which)
{
switch(which) {
case 0:
deleteAllMail(mbox->getWrapper(),folder);
break;
case 1:
deleteFolder();
break;
+ case 2:
+ downloadMails();
+ break;
default:
break;
}
}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index df916c1..d9b5558 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -108,82 +108,83 @@ public:
virtual RecBody fetchBody(const RecMail&);
bool matchName(const QString&name)const;
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
virtual const QString& Delemiter()const;
protected:
virtual void createNewFolder();
virtual void deleteFolder();
virtual void downloadMails();
Folder *folder;
IMAPviewItem *imap;
};
class MBOXviewItem : public AccountViewItem
{
friend class MBOXfolderItem;
public:
MBOXviewItem( const QString&aMboxPath, AccountView *parent );
virtual ~MBOXviewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
QStringList subFolders();
virtual void refresh(bool force=false);
protected:
virtual void createFolder();
QString m_Path;
AbstractMail *wrapper;
};
class MBOXfolderItem : public AccountViewItem
{
public:
MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after );
virtual ~MBOXfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
virtual Folder*getFolder();
protected:
+ void downloadMails();
virtual void deleteFolder();
Folder *folder;
MBOXviewItem *mbox;
};
class AccountView : public QListView
{
Q_OBJECT
public:
AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~AccountView();
virtual void populate( QList<Account> list );
virtual RecBody fetchBody(const RecMail&aMail);
virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper);
public slots:
virtual void refreshAll();
virtual void refresh(QListViewItem *item);
virtual void refreshCurrent();
virtual void slotHold(int, QListViewItem *,const QPoint&,int);
virtual void slotContextMenu(int id);
void setupFolderselect(Selectstore*sels);
signals:
void refreshMailview(QList<RecMail>*);
protected:
QListViewItem* m_currentItem;
QValueList<IMAPviewItem*> imapAccounts;
QValueList<MBOXviewItem*> mboxAccounts;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 4b4c728..0280803 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -78,48 +78,61 @@ QString AbstractMail::convert_String(const char*text)
/* cp & paste from launcher */
QString AbstractMail::gen_attachment_id()
{
QFile file( "/proc/sys/kernel/random/uuid" );
if (!file.open(IO_ReadOnly ) )
return QString::null;
QTextStream stream(&file);
return "{" + stream.read().stripWhiteSpace() + "}";
}
int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool)
{
return 0;
}
QString AbstractMail::defaultLocalfolder()
{
QString f = getenv( "HOME" );
f += "/Applications/opiemail/localmail";
return f;
}
/* temporary - will be removed when implemented in all classes */
void AbstractMail::deleteMails(const QString &,QList<RecMail> &)
{
}
void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
QList<RecMail> t;
listMessages(fromFolder->getName(),t);
encodedString*st = 0;
while (t.count()>0) {
RecMail*r = t.at(0);
st = fetchRawBody(*r);
if (st) {
targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
delete st;
}
t.removeFirst();
}
if (moveit) {
deleteAllMail(fromFolder);
}
}
+
+void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+{
+ encodedString*st = 0;
+ st = fetchRawBody(mail);
+ if (st) {
+ targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
+ delete st;
+ }
+ if (moveit) {
+ deleteMail(mail);
+ }
+}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 8debaae..f93bab4 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,64 +1,65 @@
#ifndef __abstract_mail_
#define __abstract_mail_
#include <qobject.h>
#include "settings.h"
class RecMail;
class RecBody;
class RecPart;
class IMAPwrapper;
class POP3wrapper;
class Folder;
class encodedString;
struct folderStat;
class AbstractMail:public QObject
{
Q_OBJECT
public:
AbstractMail(){};
virtual ~AbstractMail(){}
virtual QList<Folder>* listFolders()=0;
virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
virtual RecBody fetchBody(const RecMail&mail)=0;
virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchRawBody(const RecMail&mail)=0;
virtual void deleteMail(const RecMail&mail)=0;
virtual void answeredMail(const RecMail&mail)=0;
virtual int deleteAllMail(const Folder*)=0;
virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
virtual int deleteMbox(const Folder*)=0;
virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual void cleanMimeCache(){};
/* mail box methods */
/* parameter is the box to create.
* if the implementing subclass has prefixes,
* them has to be appended automatic.
*/
virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
virtual void logout()=0;
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
/* mbox only! */
static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders");
static QString defaultLocalfolder();
virtual const QString&getType()const=0;
virtual const QString&getName()const=0;
protected:
static encodedString*decode_String(const encodedString*text,const QString&enc);
static QString convert_String(const char*text);
static QString gen_attachment_id();
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 98634a3..4b633ea 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1011,48 +1011,78 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde
const QString&IMAPwrapper::getType()const
{
return account->getType();
}
const QString&IMAPwrapper::getName()const
{
qDebug("Get name: %s",account->getAccountName().latin1());
return account->getAccountName();
}
encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
{
// dummy
QValueList<int> path;
return fetchRawPart(mail,path,false);
}
void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
if (targetWrapper != this) {
AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
qDebug("Using generic");
return;
}
mailimap_set *set = 0;
login();
if (!m_imap) {
return;
}
int err = selectMbox(fromFolder->getName());
if ( err != MAILIMAP_NO_ERROR ) {
return;
}
int last = m_imap->imap_selection_info->sel_exists;
set = mailimap_set_new_interval( 1, last );
err = mailimap_copy(m_imap,set,targetFolder.latin1());
mailimap_set_free( set );
if ( err != MAILIMAP_NO_ERROR ) {
QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response);
Global::statusMessage(error_msg);
qDebug(error_msg);
return;
}
if (moveit) {
deleteAllMail(fromFolder);
}
}
+
+void IMAPwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
+{
+ if (targetWrapper != this) {
+ qDebug("Using generic");
+ AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit);
+ return;
+ }
+ mailimap_set *set = 0;
+ login();
+ if (!m_imap) {
+ return;
+ }
+ int err = selectMbox(mail.getMbox());
+ if ( err != MAILIMAP_NO_ERROR ) {
+ return;
+ }
+ set = mailimap_set_new_single(mail.getNumber());
+ err = mailimap_copy(m_imap,set,targetFolder.latin1());
+ mailimap_set_free( set );
+ if ( err != MAILIMAP_NO_ERROR ) {
+ QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response);
+ Global::statusMessage(error_msg);
+ qDebug(error_msg);
+ return;
+ }
+ if (moveit) {
+ deleteMail(mail);
+ }
+}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 99986c2..c10f86a 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -1,76 +1,77 @@
#ifndef __IMAPWRAPPER
#define __IMAPWRAPPER
#include <qlist.h>
#include "mailwrapper.h"
#include "abstractmail.h"
#include <libetpan/clist.h>
struct mailimap;
struct mailimap_body;
struct mailimap_body_type_1part;
struct mailimap_body_type_text;
struct mailimap_body_type_basic;
struct mailimap_body_type_msg;
struct mailimap_body_type_mpart;
struct mailimap_body_fields;
struct mailimap_msg_att;
class encodedString;
class IMAPwrapper : public AbstractMail
{
Q_OBJECT
public:
IMAPwrapper( IMAPaccount *a );
virtual ~IMAPwrapper();
virtual QList<Folder>* listFolders();
virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
virtual int deleteAllMail(const Folder*folder);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
+ virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual RecBody fetchBody(const RecMail&mail);
virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
virtual encodedString* fetchRawBody(const RecMail&mail);
virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
virtual int deleteMbox(const Folder*folder);
static void imap_progress( size_t current, size_t maximum );
virtual void logout();
virtual const QString&getType()const;
virtual const QString&getName()const;
protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
int selectMbox(const QString&mbox);
void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
/* just helpers */
static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
IMAPaccount *account;
mailimap *m_imap;
QString m_Lastmbox;
};
#endif
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index 1abd2e8..90e1e46 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -1,56 +1,57 @@
CONFIG += qt warn_on debug quick-app
HEADERS = defines.h \
editaccounts.h \
composemail.h \
accountview.h \
mainwindow.h \
viewmail.h \
viewmailbase.h \
opiemail.h \
mailistviewitem.h \
settingsdialog.h \
statuswidget.h \
newmaildir.h \
selectstore.h
SOURCES = main.cpp \
opiemail.cpp \
mainwindow.cpp \
accountview.cpp \
composemail.cpp \
addresspicker.cpp \
editaccounts.cpp \
viewmail.cpp \
viewmailbase.cpp \
+ mailistviewitem.cpp \
settingsdialog.cpp \
statuswidget.cpp \
newmaildir.cpp \
selectstore.cpp
INTERFACES = editaccountsui.ui \
selectmailtypeui.ui \
imapconfigui.ui \
pop3configui.ui \
nntpconfigui.ui \
smtpconfigui.ui \
addresspickerui.ui \
composemailui.ui \
settingsdialogui.ui \
statuswidgetui.ui \
newmaildirui.ui \
selectstoreui.ui
INCLUDEPATH += $(OPIEDIR)/include
CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
contains( CONFTEST, y ){
LIBS += -lqpe -lopie -lmailwrapper -liconv
}else{
LIBS += -lqpe -lopie -lmailwrapper
}
TARGET = opiemail
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp
new file mode 100644
index 0000000..f224dc3
--- a/dev/null
+++ b/noncore/net/mail/mailistviewitem.cpp
@@ -0,0 +1,65 @@
+#include "mailistviewitem.h"
+#include <qtextstream.h>
+#include <qpe/resource.h>
+
+MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
+ :QListViewItem(parent,item),mail_data()
+{
+}
+
+void MailListViewItem::showEntry()
+{
+ if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
+ setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
+ } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
+ /* I think it looks nicer if there are not such a log of icons but only on mails
+ replied or new - Alwin*/
+ //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
+ } else {
+ setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
+ }
+ double s = mail_data.Msgsize();
+ int w;
+ w=0;
+
+ while (s>1024) {
+ s/=1024;
+ ++w;
+ if (w>=2) break;
+ }
+
+ QString q="";
+ QString fsize="";
+ switch(w) {
+ case 1:
+ q="k";
+ break;
+ case 2:
+ q="M";
+ break;
+ default:
+ break;
+ }
+
+ {
+ QTextOStream o(&fsize);
+ if (w>0) o.precision(2); else o.precision(0);
+ o.setf(QTextStream::fixed);
+ o << s << " " << q << "Byte";
+ }
+
+ setText(1,mail_data.getSubject());
+ setText(2,mail_data.getFrom());
+ setText(3,fsize);
+ setText(4,mail_data.getDate());
+}
+
+void MailListViewItem::storeData(const RecMail&data)
+{
+ mail_data = data;
+}
+
+const RecMail& MailListViewItem::data()const
+{
+ return mail_data;
+}
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h
index 271f616..3b352a2 100644
--- a/noncore/net/mail/mailistviewitem.h
+++ b/noncore/net/mail/mailistviewitem.h
@@ -1,22 +1,21 @@
#ifndef __MAILLISTVIEWITEM_H
#define __MAILLISTVIEWITEM_H
#include <qlistview.h>
#include <libmailwrapper/mailtypes.h>
-
class MailListViewItem:public QListViewItem
{
public:
MailListViewItem(QListView * parent, MailListViewItem * after );
virtual ~MailListViewItem(){}
void storeData(const RecMail&data);
const RecMail&data()const;
void showEntry();
protected:
RecMail mail_data;
};
#endif
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index e16f853..c38392c 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,65 +1,60 @@
#include <qlabel.h>
#include <qvbox.h>
#include <qheader.h>
#include <qtimer.h>
#include <qlayout.h>
#include <qmessagebox.h>
-#include <qtextstream.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
-
#include "defines.h"
#include "mainwindow.h"
-#include "viewmail.h"
-#include <libmailwrapper/mailtypes.h>
-#include "mailistviewitem.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
: QMainWindow( parent, name, flags )
{
setCaption( tr( "Mail" ) );
setToolBarsMovable( false );
toolBar = new QToolBar( this );
menuBar = new QMenuBar( toolBar );
mailMenu = new QPopupMenu( menuBar );
menuBar->insertItem( tr( "Mail" ), mailMenu );
settingsMenu = new QPopupMenu( menuBar );
menuBar->insertItem( tr( "Settings" ), settingsMenu );
addToolBar( toolBar );
toolBar->setHorizontalStretchable( true );
QLabel *spacer = new QLabel( toolBar );
spacer->setBackgroundMode( QWidget::PaletteButton );
toolBar->setStretchableWidget( spacer );
composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
0, 0, this );
composeMail->addTo( toolBar );
composeMail->addTo( mailMenu );
sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
0, 0, this );
sendQueued->addTo( toolBar );
sendQueued->addTo( mailMenu );
/*
syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
0, 0, this );
syncFolders->addTo( toolBar );
syncFolders->addTo( mailMenu );
*/
showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
0, 0, this, 0, true );
showFolders->addTo( toolBar );
showFolders->addTo( mailMenu );
showFolders->setOn( true );
connect(showFolders, SIGNAL( toggled( bool ) ),
SLOT( slotShowFolders( bool ) ) );
@@ -82,223 +77,129 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
connect( editSettings, SIGNAL( activated() ),
SLOT( slotEditSettings() ) );
editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) ,
0, 0, this );
editAccounts->addTo( settingsMenu );
//setCentralWidget( view );
QVBox* wrapperBox = new QVBox( this );
setCentralWidget( wrapperBox );
QWidget *view = new QWidget( wrapperBox );
layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
folderView = new AccountView( view );
folderView->header()->hide();
folderView->setRootIsDecorated( true );
folderView->addColumn( tr( "Mailbox" ) );
layout->addWidget( folderView );
mailView = new QListView( view );
mailView->addColumn( tr( "" ) );
mailView->addColumn( tr( "Subject" ),QListView::Manual );
mailView->addColumn( tr( "Sender" ),QListView::Manual );
mailView->addColumn( tr( "Size" ),QListView::Manual);
mailView->addColumn( tr( "Date" ));
mailView->setAllColumnsShowFocus(true);
mailView->setSorting(-1);
statusWidget = new StatusWidget( wrapperBox );
statusWidget->hide();
layout->addWidget( mailView );
layout->setStretchFactor( folderView, 1 );
layout->setStretchFactor( mailView, 2 );
slotAdjustLayout();
QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
connect( mailView, SIGNAL( mouseButtonClicked(int, QListViewItem *,const QPoint&,int ) ),this,
SLOT( mailLeftClicked( int, QListViewItem *,const QPoint&,int ) ) );
connect( mailView, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
SLOT( mailHold( int, QListViewItem *,const QPoint&,int ) ) );
connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
+ connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
+ connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
+// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
+ connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
+ // Added by Stefan Eilers to allow starting by addressbook..
+ // copied from old mail2
+#if !defined(QT_NO_COP)
+ connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ),
+ this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
+#endif
QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
}
MainWindow::~MainWindow()
{
}
+void MainWindow::appMessage(const QCString &, const QByteArray &)
+{
+ qDebug("appMessage not reached");
+}
+
void MainWindow::slotAdjustLayout() {
QWidget *d = QApplication::desktop();
if ( d->width() < d->height() ) {
layout->setDirection( QBoxLayout::TopToBottom );
} else {
layout->setDirection( QBoxLayout::LeftToRight );
}
}
void MainWindow::slotAdjustColumns()
{
bool hidden = folderView->isHidden();
if ( hidden ) folderView->show();
folderView->setColumnWidth( 0, folderView->visibleWidth() );
if ( hidden ) folderView->hide();
mailView->setColumnWidth( 0, 10 );
mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
mailView->setColumnWidth( 2, 80 );
mailView->setColumnWidth( 3, 50 );
mailView->setColumnWidth( 4, 50 );
}
void MainWindow::slotEditSettings()
{
}
-void MainWindow::slotShowFolders( bool show )
+void MainWindow::slotShowFolders( bool )
{
- qDebug( "Show Folders" );
- if ( show && folderView->isHidden() ) {
- qDebug( "-> showing" );
- folderView->show();
- } else if ( !show && !folderView->isHidden() ) {
- qDebug( "-> hiding" );
- folderView->hide();
- }
+ qDebug( "slotShowFolders not reached" );
}
-void MainWindow::refreshMailView(QList<RecMail>*list)
+void MainWindow::refreshMailView(QList<RecMail>*)
{
- MailListViewItem*item = 0;
- mailView->clear();
- for (unsigned int i = 0; i < list->count();++i) {
- item = new MailListViewItem(mailView,item);
- item->storeData(*(list->at(i)));
- item->showEntry();
- }
+ qDebug( "refreshMailView not reached" );
}
-void MainWindow::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
+
+void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int )
{
- /* just LEFT button - or tap with stylus on pda */
- if (button!=1) return;
- if (!item) return;
- displayMail();
+ qDebug( "mailLeftClicked not reached" );
}
void MainWindow::displayMail()
{
- QListViewItem*item = mailView->currentItem();
- if (!item) return;
- RecMail mail = ((MailListViewItem*)item)->data();
- RecBody body = folderView->fetchBody(mail);
- ViewMail readMail( this );
- readMail.setBody( body );
- readMail.setMail( mail );
- readMail.showMaximized();
- readMail.exec();
-
- if ( readMail.deleted ) {
- folderView->refreshCurrent();
- } else {
- ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") );
- }
+ qDebug("displayMail not reached");
}
void MainWindow::slotDeleteMail()
{
- if (!mailView->currentItem()) return;
- RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
- if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
- mail.Wrapper()->deleteMail( mail );
- folderView->refreshCurrent();
- }
-}
-
-void MainWindow::mailHold(int button, QListViewItem *item,const QPoint&,int )
-{
- /* just the RIGHT button - or hold on pda */
- if (button!=2) {return;}
- qDebug("Event right/hold");
- if (!item) return;
- QPopupMenu *m = new QPopupMenu(0);
- if (m) {
- m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
- m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
- m->setFocus();
- m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
- delete m;
- }
-}
-
-MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
- :QListViewItem(parent,item),mail_data()
-{
-}
-
-void MailListViewItem::showEntry()
-{
- if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
- setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
- } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
- /* I think it looks nicer if there are not such a log of icons but only on mails
- replied or new - Alwin*/
- //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
- } else {
- setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
- }
- double s = mail_data.Msgsize();
- int w;
- w=0;
-
- while (s>1024) {
- s/=1024;
- ++w;
- if (w>=2) break;
- }
-
- QString q="";
- QString fsize="";
- switch(w) {
- case 1:
- q="k";
- break;
- case 2:
- q="M";
- break;
- default:
- break;
- }
-
- {
- QTextOStream o(&fsize);
- if (w>0) o.precision(2); else o.precision(0);
- o.setf(QTextStream::fixed);
- o << s << " " << q << "Byte";
- }
-
- setText(1,mail_data.getSubject());
- setText(2,mail_data.getFrom());
- setText(3,fsize);
- setText(4,mail_data.getDate());
+ qDebug("deleteMail not reached");
}
-void MailListViewItem::storeData(const RecMail&data)
+void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
{
- mail_data = data;
+ qDebug("mailHold not reached");
}
-
-const RecMail& MailListViewItem::data()const
-{
- return mail_data;
-}
-
-
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 15d216a..20614cc 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -1,49 +1,50 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qlistview.h>
#include <qaction.h>
#include <qtoolbar.h>
#include <qmenubar.h>
#include "accountview.h"
#include "statuswidget.h"
class RecMail;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~MainWindow();
public slots:
virtual void slotAdjustColumns();
+ virtual void appMessage(const QCString &msg, const QByteArray &data);
protected slots:
virtual void slotShowFolders( bool show );
virtual void refreshMailView(QList<RecMail>*);
virtual void displayMail();
virtual void slotDeleteMail();
virtual void mailHold(int, QListViewItem *,const QPoint&,int);
virtual void slotAdjustLayout();
virtual void slotEditSettings();
virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
protected:
QToolBar *toolBar;
StatusWidget *statusWidget;
QMenuBar *menuBar;
QPopupMenu *mailMenu, *settingsMenu;
QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
*editSettings, *editAccounts, *syncFolders;
AccountView *folderView;
QListView *mailView;
QBoxLayout *layout;
};
#endif
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index c888708..dee3f70 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,120 +1,211 @@
#include <qmessagebox.h>
#include "settingsdialog.h"
#include "opiemail.h"
#include "editaccounts.h"
#include "composemail.h"
#include <libmailwrapper/smtpwrapper.h>
#include <qpe/qcopenvelope_qws.h>
+#include <qpe/resource.h>
#include <qaction.h>
#include <qapplication.h>
+#include <libmailwrapper/mailtypes.h>
+#include "mailistviewitem.h"
+#include "viewmail.h"
+#include "selectstore.h"
OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
: MainWindow( parent, name, flags )
{
settings = new Settings();
folderView->populate( settings->getAccounts() );
-
- connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
- connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
-// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
- connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
- // Added by Stefan Eilers to allow starting by addressbook..
- // copied from old mail2
-#if !defined(QT_NO_COP)
- connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ),
- this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
-#endif
-
-
-
}
OpieMail::~OpieMail()
{
if (settings) delete settings;
}
void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
{
// copied from old mail2
if (msg == "writeMail(QString,QString)") {
QDataStream stream(data,IO_ReadOnly);
QString name, email;
stream >> name >> email;
// removing the whitespaces at beginning and end is needed!
slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
} else if (msg == "newMail()") {
slotComposeMail();
}
}
void OpieMail::slotwriteMail(const QString&name,const QString&email)
{
ComposeMail compose( settings, this, 0 , true );
if (!email.isEmpty()) {
if (!name.isEmpty()) {
compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
} else {
compose.setTo(email);
}
}
compose.showMaximized();
compose.slotAdjustColumns();
compose.exec();
}
void OpieMail::slotComposeMail()
{
qDebug( "Compose Mail" );
slotwriteMail(0l,0l);
}
void OpieMail::slotSendQueued()
{
qDebug( "Send Queued" );
SMTPaccount *smtp = 0;
QList<Account> list = settings->getAccounts();
Account *it;
// if (list.count()==1) {
for ( it = list.first(); it; it = list.next() ) {
if ( it->getType().compare( "SMTP" ) == 0 ) {
smtp = static_cast<SMTPaccount *>(it);
break;
}
}
// }
if (smtp) {
SMTPwrapper * wrap = new SMTPwrapper(settings);
if ( wrap->flushOutbox(smtp) ) {
QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
}
}
}
void OpieMail::slotSearchMails()
{
qDebug( "Search Mails" );
}
void OpieMail::slotEditSettings()
{
SettingsDialog settingsDialog( this, 0, true );
settingsDialog.showMaximized();
settingsDialog.exec();
}
void OpieMail::slotEditAccounts()
{
qDebug( "Edit Accounts" );
EditAccounts eaDialog( settings, this, 0, true );
eaDialog.showMaximized();
eaDialog.slotAdjustColumns();
eaDialog.exec();
if ( settings ) delete settings;
settings = new Settings();
folderView->populate( settings->getAccounts() );
}
+void OpieMail::displayMail()
+{
+ QListViewItem*item = mailView->currentItem();
+ if (!item) return;
+ RecMail mail = ((MailListViewItem*)item)->data();
+ RecBody body = folderView->fetchBody(mail);
+ ViewMail readMail( this );
+ readMail.setBody( body );
+ readMail.setMail( mail );
+ readMail.showMaximized();
+ readMail.exec();
+
+ if ( readMail.deleted ) {
+ folderView->refreshCurrent();
+ } else {
+ ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") );
+ }
+}
+
+void OpieMail::slotDeleteMail()
+{
+ if (!mailView->currentItem()) return;
+ RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
+ if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
+ mail.Wrapper()->deleteMail( mail );
+ folderView->refreshCurrent();
+ }
+}
+
+void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
+{
+ /* just the RIGHT button - or hold on pda */
+ if (button!=2) {return;}
+ qDebug("Event right/hold");
+ if (!item) return;
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
+ m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
+ m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
+ m->setFocus();
+ m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
+ delete m;
+ }
+}
+
+void OpieMail::slotShowFolders( bool show )
+{
+ qDebug( "Show Folders" );
+ if ( show && folderView->isHidden() ) {
+ qDebug( "-> showing" );
+ folderView->show();
+ } else if ( !show && !folderView->isHidden() ) {
+ qDebug( "-> hiding" );
+ folderView->hide();
+ }
+}
+
+void OpieMail::refreshMailView(QList<RecMail>*list)
+{
+ MailListViewItem*item = 0;
+ mailView->clear();
+ for (unsigned int i = 0; i < list->count();++i) {
+ item = new MailListViewItem(mailView,item);
+ item->storeData(*(list->at(i)));
+ item->showEntry();
+ }
+}
+
+void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
+{
+ /* just LEFT button - or tap with stylus on pda */
+ if (button!=1) return;
+ if (!item) return;
+ displayMail();
+}
+
+void OpieMail::slotMoveCopyMail()
+{
+ if (!mailView->currentItem()) return;
+ RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
+ AbstractMail*targetMail = 0;
+ QString targetFolder = "";
+ Selectstore sels;
+ folderView->setupFolderselect(&sels);
+ if (!sels.exec()) return;
+ targetMail = sels.currentMail();
+ targetFolder = sels.currentFolder();
+ if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) ||
+ targetFolder.isEmpty()) {
+ return;
+ }
+ if (sels.newFolder() && !targetMail->createMbox(targetFolder)) {
+ QMessageBox::critical(0,tr("Error creating new Folder"),
+ tr("<center>Error while creating<br>new folder - breaking.</center>"));
+ return;
+ }
+ mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
+ folderView->refreshCurrent();
+}
diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h
index 69b8d43..5821856 100644
--- a/noncore/net/mail/opiemail.h
+++ b/noncore/net/mail/opiemail.h
@@ -1,31 +1,39 @@
#ifndef OPIEMAIL_H
#define OPIEMAIL_H
#include "mainwindow.h"
#include <libmailwrapper/settings.h>
class OpieMail : public MainWindow
{
Q_OBJECT
public:
OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~OpieMail();
static QString appName() { return QString::fromLatin1("opiemail"); }
public slots:
virtual void slotwriteMail(const QString&name,const QString&email);
virtual void slotComposeMail();
virtual void appMessage(const QCString &msg, const QByteArray &data);
protected slots:
virtual void slotSendQueued();
virtual void slotSearchMails();
virtual void slotEditSettings();
virtual void slotEditAccounts();
+ virtual void displayMail();
+ virtual void slotDeleteMail();
+ virtual void mailHold(int, QListViewItem *,const QPoint&,int);
+ virtual void slotShowFolders( bool show );
+ virtual void refreshMailView(QList<RecMail>*);
+ virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
+ virtual void slotMoveCopyMail();
+
private:
Settings *settings;
};
#endif