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
@@ -874,2 +874,3 @@ QPopupMenu * MBOXfolderItem::getContextMenu()
m->insertItem(QObject::tr("Delete folder",contextName),1);
+ m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
}
@@ -878,2 +879,9 @@ QPopupMenu * MBOXfolderItem::getContextMenu()
+void MBOXfolderItem::downloadMails()
+{
+ AccountView*bl = mbox->accountView();
+ if (!bl) return;
+ bl->downloadMails(folder,mbox->getWrapper());
+}
+
void MBOXfolderItem::contextMenuSelected(int which)
@@ -887,2 +895,5 @@ void MBOXfolderItem::contextMenuSelected(int which)
break;
+ case 2:
+ downloadMails();
+ break;
default:
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
@@ -155,2 +155,3 @@ public:
protected:
+ void downloadMails();
virtual void deleteFolder();
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
@@ -125 +125,14 @@ void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abs
}
+
+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
@@ -38,2 +38,3 @@ public:
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);
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
@@ -1058 +1058,31 @@ void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,Abst
}
+
+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
@@ -34,2 +34,3 @@ public:
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);
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
@@ -25,2 +25,3 @@ SOURCES = main.cpp \
viewmailbase.cpp \
+ mailistviewitem.cpp \
settingsdialog.cpp \
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
@@ -6,3 +6,2 @@
-
class MailListViewItem:public QListViewItem
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
@@ -6,3 +6,2 @@
#include <qmessagebox.h>
-#include <qtextstream.h>
@@ -11,8 +10,4 @@
-
#include "defines.h"
#include "mainwindow.h"
-#include "viewmail.h"
-#include <libmailwrapper/mailtypes.h>
-#include "mailistviewitem.h"
@@ -129,2 +124,12 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
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
@@ -137,2 +142,7 @@ MainWindow::~MainWindow()
+void MainWindow::appMessage(const QCString &, const QByteArray &)
+{
+ qDebug("appMessage not reached");
+}
+
void MainWindow::slotAdjustLayout() {
@@ -166,30 +176,15 @@ 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" );
}
@@ -198,17 +193,3 @@ 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");
}
@@ -217,88 +198,8 @@ 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
@@ -25,2 +25,3 @@ public slots:
virtual void slotAdjustColumns();
+ virtual void appMessage(const QCString &msg, const QByteArray &data);
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
@@ -7,4 +7,9 @@
#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"
@@ -16,16 +21,2 @@ OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
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
-
-
-
}
@@ -120 +111,101 @@ void OpieMail::slotEditAccounts()
+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
@@ -25,2 +25,10 @@ protected slots:
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: