summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-07 19:27:47 (UTC)
committer alwin <alwin>2004-01-07 19:27:47 (UTC)
commit24a62e8789083f446138aebfa11409b73886aa88 (patch) (side-by-side diff)
tree177bd3de4ad46fd29e93b87c6a0423a4ca132682
parent7fdc50c5ff3fe42aba6d940165e99ed7150df4f1 (diff)
downloadopie-24a62e8789083f446138aebfa11409b73886aa88.zip
opie-24a62e8789083f446138aebfa11409b73886aa88.tar.gz
opie-24a62e8789083f446138aebfa11409b73886aa88.tar.bz2
download mail mostly finished
accounts can be switched "offline"
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp234
-rw-r--r--noncore/net/mail/accountview.h71
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp9
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h4
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp6
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp9
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h6
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp6
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp12
-rw-r--r--noncore/net/mail/libmailwrapper/settings.h5
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp10
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h4
-rw-r--r--noncore/net/mail/selectstore.cpp53
-rw-r--r--noncore/net/mail/selectstore.h18
-rw-r--r--noncore/net/mail/selectstoreui.ui43
17 files changed, 415 insertions, 78 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index faa6982..eea021f 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -9,9 +9,9 @@
/**
* POP3 Account stuff
*/
-POP3viewItem::POP3viewItem( POP3account *a, QListView *parent )
+POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
@@ -31,8 +31,9 @@ AbstractMail *POP3viewItem::getWrapper()
}
void POP3viewItem::refresh( QList<RecMail> & )
{
+ if (account->getOffline()) return;
QList<Folder> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child ) {
QListViewItem *tmp = child;
@@ -55,8 +56,54 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail )
qDebug( "POP3 fetchBody" );
return wrapper->fetchBody( mail );
}
+QPopupMenu * POP3viewItem::getContextMenu()
+{
+ QPopupMenu *m = new QPopupMenu(0);
+ if (m) {
+ if (!account->getOffline()) {
+ m->insertItem(QObject::tr("Disconnect",contextName),0);
+ m->insertItem(QObject::tr("Set offline",contextName),1);
+ } else {
+ m->insertItem(QObject::tr("Set online",contextName),1);
+ }
+ }
+ return m;
+}
+
+void POP3viewItem::disconnect()
+{
+ QListViewItem *child = firstChild();
+ while ( child ) {
+ QListViewItem *tmp = child;
+ child = child->nextSibling();
+ delete tmp;
+ }
+ wrapper->logout();
+}
+
+void POP3viewItem::setOnOffline()
+{
+ if (!account->getOffline()) {
+ disconnect();
+ }
+ account->setOffline(!account->getOffline());
+ account->save();
+}
+
+void POP3viewItem::contextMenuSelected(int which)
+{
+ switch (which) {
+ case 0:
+ disconnect();
+ break;
+ case 1:
+ setOnOffline();
+ break;
+ }
+}
+
POP3folderItem::~POP3folderItem()
{
delete folder;
}
@@ -90,18 +137,18 @@ QPopupMenu * POP3folderItem::getContextMenu()
QPopupMenu *m = new QPopupMenu(0);
if (m) {
m->insertItem(QObject::tr("Refresh header list",contextName),0);
m->insertItem(QObject::tr("Delete all mails",contextName),1);
- m->insertItem(QObject::tr("Download all mails",contextName),2);
+ m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
}
return m;
}
void POP3folderItem::downloadMails()
{
- Selectstore sels;
- sels.showMaximized();
- sels.exec();
+ AccountView*bl = pop3->accountView();
+ if (!bl) return;
+ bl->downloadMails(folder,pop3->getWrapper());
}
void POP3folderItem::contextMenuSelected(int which)
{
@@ -125,9 +172,9 @@ void POP3folderItem::contextMenuSelected(int which)
/**
* IMAP Account stuff
*/
-IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
+IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
@@ -182,14 +229,20 @@ void IMAPviewItem::removeChilds()
}
}
+const QStringList&IMAPviewItem::subFolders()
+{
+ return currentFolders;
+}
+
void IMAPviewItem::refreshFolders(bool force)
{
if (childCount()>0 && force==false) return;
-
- removeChilds();
+ if (account->getOffline()) return;
+ removeChilds();
+ currentFolders.clear();
QList<Folder> *folders = wrapper->listFolders();
Folder *it;
QListViewItem*item = 0;
@@ -208,8 +261,9 @@ void IMAPviewItem::refreshFolders(bool force)
}
}
for ( it = folders->first(); it; it = folders->next() ) {
fname = it->getDisplayName();
+ currentFolders.append(it->getName());
pos = fname.findRev(it->Separator());
if (pos != -1) {
fname = fname.left(pos);
}
@@ -230,12 +284,17 @@ void IMAPviewItem::refreshFolders(bool force)
QPopupMenu * IMAPviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m) {
- m->insertItem(QObject::tr("Refresh folder list",contextName),0);
- m->insertItem(QObject::tr("Create new folder",contextName),1);
- m->insertSeparator();
- m->insertItem(QObject::tr("Disconnect",contextName),2);
+ if (!account->getOffline()) {
+ m->insertItem(QObject::tr("Refresh folder list",contextName),0);
+ m->insertItem(QObject::tr("Create new folder",contextName),1);
+ m->insertSeparator();
+ m->insertItem(QObject::tr("Disconnect",contextName),2);
+ m->insertItem(QObject::tr("Set offline",contextName),3);
+ } else {
+ m->insertItem(QObject::tr("Set online",contextName),3);
+ }
}
return m;
}
@@ -270,8 +329,17 @@ void IMAPviewItem::contextMenuSelected(int id)
case 2:
removeChilds();
wrapper->logout();
break;
+ case 3:
+ if (account->getOffline()==false) {
+ removeChilds();
+ wrapper->logout();
+ }
+ account->setOffline(!account->getOffline());
+ account->save();
+ refreshFolders(false);
+ break;
default:
break;
}
}
@@ -280,11 +348,11 @@ RecBody IMAPviewItem::fetchBody(const RecMail&)
{
return RecBody();
}
-IMAPfolderItem::~IMAPfolderItem()
+bool IMAPviewItem::offline()
{
- delete folder;
+ return account->getOffline();
}
IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
: AccountViewItem( parent , after )
@@ -311,8 +379,13 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi
}
setText( 0, folder->getDisplayName() );
}
+IMAPfolderItem::~IMAPfolderItem()
+{
+ delete folder;
+}
+
const QString& IMAPfolderItem::Delemiter()const
{
return folder->Separator();
}
@@ -341,8 +414,9 @@ QPopupMenu * IMAPfolderItem::getContextMenu()
QPopupMenu *m = new QPopupMenu(0);
if (m) {
if (folder->may_select()) {
m->insertItem(QObject::tr("Refresh header list",contextName),0);
+ m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
m->insertItem(QObject::tr("Delete all mails",contextName),1);
}
if (folder->no_inferior()==false) {
m->insertItem(QObject::tr("Create new subfolder",contextName),2);
@@ -388,8 +462,15 @@ void IMAPfolderItem::deleteFolder()
}
}
}
+void IMAPfolderItem::downloadMails()
+{
+ AccountView*bl = imap->accountView();
+ if (!bl) return;
+ bl->downloadMails(folder,imap->getWrapper());
+}
+
void IMAPfolderItem::contextMenuSelected(int id)
{
qDebug("Selected id: %i",id);
AccountView * view = (AccountView*)listView();
@@ -405,8 +486,11 @@ void IMAPfolderItem::contextMenuSelected(int id)
break;
case 3:
deleteFolder();
break;
+ case 4:
+ downloadMails();
+ break;
default:
break;
}
}
@@ -416,8 +500,35 @@ void IMAPfolderItem::contextMenuSelected(int id)
*/
const QString AccountViewItem::contextName="AccountViewItem";
+AccountViewItem::AccountViewItem( AccountView *parent )
+ : QListViewItem( parent )
+{
+ m_Backlink = parent;
+}
+
+AccountViewItem::AccountViewItem( QListViewItem *parent)
+ : QListViewItem( parent)
+{
+ m_Backlink = 0;
+}
+
+AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
+ :QListViewItem( parent,after )
+{
+ m_Backlink = 0;
+}
+
+AccountViewItem::~AccountViewItem()
+{
+}
+
+AccountView*AccountViewItem::accountView()
+{
+ return m_Backlink;
+}
+
void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
{
if (!wrapper) return;
QString fname="";
@@ -446,8 +557,14 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
setSorting(0);
}
+AccountView::~AccountView()
+{
+ imapAccounts.clear();
+ mboxAccounts.clear();
+}
+
void AccountView::slotContextMenu(int id)
{
AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
if (!view) return;
@@ -470,19 +587,23 @@ void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
void AccountView::populate( QList<Account> list )
{
clear();
- (void) new MBOXviewItem(AbstractMail::defaultLocalfolder(),this);
+ imapAccounts.clear();
+ mboxAccounts.clear();
+
+ mboxAccounts.append(new MBOXviewItem(AbstractMail::defaultLocalfolder(),this));
Account *it;
for ( it = list.first(); it; it = list.next() ) {
if ( it->getType().compare( "IMAP" ) == 0 ) {
IMAPaccount *imap = static_cast<IMAPaccount *>(it);
qDebug( "added IMAP " + imap->getAccountName() );
- (void) new IMAPviewItem( imap, this );
+ imapAccounts.append(new IMAPviewItem( imap, this ));
} else if ( it->getType().compare( "POP3" ) == 0 ) {
POP3account *pop3 = static_cast<POP3account *>(it);
qDebug( "added POP3 " + pop3->getAccountName() );
+ /* must not be hold 'cause it isn't required */
(void) new POP3viewItem( pop3, this );
}
}
}
@@ -502,14 +623,14 @@ void AccountView::refresh(QListViewItem *item) {
void AccountView::refreshCurrent()
{
m_currentItem = currentItem();
- if ( !m_currentItem ) return;
- QList<RecMail> headerlist;
- headerlist.setAutoDelete(true);
- AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
- view->refresh(headerlist);
- emit refreshMailview(&headerlist);
+ if ( !m_currentItem ) return;
+ QList<RecMail> headerlist;
+ headerlist.setAutoDelete(true);
+ AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
+ view->refresh(headerlist);
+ emit refreshMailview(&headerlist);
}
void AccountView::refreshAll()
{
@@ -523,17 +644,64 @@ RecBody AccountView::fetchBody(const RecMail&aMail)
AccountViewItem *view = static_cast<AccountViewItem *>(item);
return view->fetchBody(aMail);
}
+void AccountView::setupFolderselect(Selectstore*sels)
+{
+ sels->showMaximized();
+ QStringList sFolders;
+ unsigned int i = 0;
+ for (i=0; i < mboxAccounts.count();++i) {
+ mboxAccounts[i]->refresh(false);
+ sFolders = mboxAccounts[i]->subFolders();
+ sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders);
+ }
+ for (i=0; i < imapAccounts.count();++i) {
+ if (imapAccounts[i]->offline())
+ continue;
+ imapAccounts[i]->refreshFolders(false);
+ sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
+ }
+}
+
+void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
+{
+ unsigned int i = 0;
+ AbstractMail*targetMail = 0;
+ QString targetFolder = "";
+ Selectstore sels;
+ setupFolderselect(&sels);
+ if (!sels.exec()) return;
+ targetMail = sels.currentMail();
+ targetFolder = sels.currentFolder();
+ if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
+ targetFolder.isEmpty()) {
+ return;
+ }
+
+ QList<RecMail> t;
+ fromWrapper->listMessages(fromFolder->getName(),t);
+ encodedString*st = 0;
+ for (i = 0; i < t.count();++i) {
+ RecMail*r = t.at(i);
+ st = fromWrapper->fetchRawBody(*r);
+ if (st) {
+ targetMail->storeMessage(st->Content(),st->Length(),targetFolder);
+ delete st;
+ }
+ }
+}
+
/**
* MBOX Account stuff
*/
-MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent )
+MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent )
: AccountViewItem( parent )
{
m_Path = aPath;
- wrapper = AbstractMail::getWrapper( m_Path );
+ /* be carefull - the space within settext is wanted - thats why the string twice */
+ wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
setPixmap( 0, PIXMAP_LOCALFOLDER );
setText( 0, " Local Folders" );
setOpen( true );
}
@@ -601,8 +769,21 @@ void MBOXviewItem::createFolder()
}
}
}
+QStringList MBOXviewItem::subFolders()
+{
+ QStringList result;
+ QListViewItem *child = firstChild();
+ while ( child ) {
+ MBOXfolderItem *tmp = (MBOXfolderItem*)child;
+ child = child->nextSibling();
+ result.append(tmp->getFolder()->getName());
+ }
+ qDebug("Size of result: %i",result.count());
+ return result;
+}
+
void MBOXviewItem::contextMenuSelected(int which)
{
switch (which) {
case 0:
@@ -635,8 +816,13 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList
}
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 );
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 7131192..48f52c7 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -11,55 +11,62 @@
class POP3wrapper;
class RecMail;
class RecBody;
class QPopupMenu;
+class Selectstore;
+class AccountView;
class AccountViewItem : public QListViewItem
{
public:
- AccountViewItem( QListView *parent ) : QListViewItem( parent ) {}
- AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {}
- AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {}
+ AccountViewItem( AccountView *parent );
+ AccountViewItem( QListViewItem *parent);
+ AccountViewItem( QListViewItem *parent , QListViewItem*after );
+ virtual ~AccountViewItem();
virtual void refresh(QList<RecMail>&)=0;
virtual RecBody fetchBody(const RecMail&)=0;
virtual QPopupMenu * getContextMenu(){return 0;};
virtual void contextMenuSelected(int){}
+ virtual AccountView*accountView();
protected:
virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
static const QString contextName;
+ AccountView*m_Backlink;
};
class POP3viewItem : public AccountViewItem
{
public:
- POP3viewItem( POP3account *a, QListView *parent );
- ~POP3viewItem();
+ POP3viewItem( POP3account *a, AccountView *parent );
+ virtual ~POP3viewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
AbstractMail *getWrapper();
-private:
+ virtual QPopupMenu * getContextMenu();
+ virtual void contextMenuSelected(int);
+
+protected:
POP3account *account;
AbstractMail *wrapper;
-
+ void disconnect();
+ void setOnOffline();
};
class POP3folderItem : public AccountViewItem
{
public:
POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
- ~POP3folderItem();
+ virtual ~POP3folderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
void downloadMails();
-
-private:
Folder *folder;
POP3viewItem *pop3;
};
@@ -68,34 +75,35 @@ class IMAPfolderItem;
class IMAPviewItem : public AccountViewItem
{
friend class IMAPfolderItem;
public:
- IMAPviewItem( IMAPaccount *a, QListView *parent );
- ~IMAPviewItem();
+ IMAPviewItem( IMAPaccount *a, AccountView *parent );
+ virtual ~IMAPviewItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
+ const QStringList&subFolders();
+ virtual void refreshFolders(bool force=false);
+ bool offline();
protected:
IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0);
- virtual void refreshFolders(bool force=false);
virtual void createNewFolder();
virtual void removeChilds();
-
-private:
IMAPaccount *account;
AbstractMail *wrapper;
+ QStringList currentFolders;
};
class IMAPfolderItem : public AccountViewItem
{
public:
IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
- ~IMAPfolderItem();
+ virtual ~IMAPfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
bool matchName(const QString&name)const;
virtual QPopupMenu * getContextMenu();
@@ -103,10 +111,9 @@ public:
virtual const QString& Delemiter()const;
protected:
virtual void createNewFolder();
virtual void deleteFolder();
-
-private:
+ virtual void downloadMails();
Folder *folder;
IMAPviewItem *imap;
};
@@ -114,23 +121,20 @@ class MBOXviewItem : public AccountViewItem
{
friend class MBOXfolderItem;
public:
-// MBOXviewItem( MBOXaccount *a, QListView *parent );
- MBOXviewItem( const QString&aMboxPath, QListView *parent );
- ~MBOXviewItem();
+ 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 refresh(bool force=false);
virtual void createFolder();
-
-private:
-// MBOXaccount *account;
QString m_Path;
AbstractMail *wrapper;
};
@@ -139,17 +143,17 @@ class MBOXfolderItem : public AccountViewItem
{
public:
MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after );
- ~MBOXfolderItem();
+ virtual ~MBOXfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
+ virtual Folder*getFolder();
protected:
virtual void deleteFolder();
-private:
Folder *folder;
MBOXviewItem *mbox;
};
@@ -158,22 +162,27 @@ class AccountView : public QListView
Q_OBJECT
public:
AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
- void populate( QList<Account> list );
- RecBody fetchBody(const RecMail&aMail);
+ 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>*);
-private:
- QListViewItem* m_currentItem;
+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 80d0b52..3dd2fce 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -20,11 +20,11 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a)
{
return new POP3wrapper(a);
}
-AbstractMail* AbstractMail::getWrapper(const QString&a)
+AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name)
{
- return new MBOXwrapper(a);
+ return new MBOXwrapper(a,name);
}
encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
{
@@ -98,4 +98,9 @@ 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> &)
+{
+}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 9770991..15d83cb 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -30,8 +30,9 @@ public:
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 cleanMimeCache(){};
@@ -45,13 +46,14 @@ public:
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
/* mbox only! */
- static AbstractMail* getWrapper(const QString&a);
+ 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);
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index d252159..bb74de9 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -28,8 +28,9 @@ void IMAPwrapper::login()
const char *server, *user, *pass;
uint16_t port;
int err = MAILIMAP_NO_ERROR;
+ if (account->getOffline()) return;
/* we are connected this moment */
/* TODO: setup a timer holding the line or if connection closed - delete the value */
if (m_imap) {
err = mailimap_noop(m_imap);
@@ -1005,8 +1006,13 @@ const QString&IMAPwrapper::getType()const
{
return account->getType();
}
+const QString&IMAPwrapper::getName()const
+{
+ return account->getAccountName();
+}
+
encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
{
// dummy
QValueList<int> path;
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index b246f58..b2bd7e9 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -44,8 +44,10 @@ public:
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();
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index bc496f7..97f301e 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -7,10 +7,10 @@
#include <qpe/global.h>
const QString MBOXwrapper::wrapperType="MBOX";
-MBOXwrapper::MBOXwrapper(const QString & mbox_dir)
- : Genericwrapper(),MBOXPath(mbox_dir)
+MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name)
+ : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name)
{
QDir dir(MBOXPath);
if (!dir.exists()) {
dir.mkdir(MBOXPath);
@@ -329,4 +329,9 @@ void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
const QString&MBOXwrapper::getType()const
{
return wrapperType;
}
+
+const QString&MBOXwrapper::getName()const
+{
+ return MBOXName;
+}
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index 2794014..194ff86 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -12,9 +12,9 @@ struct mailmbox_folder;
class MBOXwrapper : public Genericwrapper
{
Q_OBJECT
public:
- MBOXwrapper(const QString & dir);
+ MBOXwrapper(const QString & dir,const QString&name);
virtual ~MBOXwrapper();
virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
virtual QList<Folder>* listFolders();
@@ -31,15 +31,17 @@ public:
virtual RecBody fetchBody( const RecMail &mail );
static void mbox_progress( size_t current, size_t maximum );
virtual encodedString* fetchRawBody(const RecMail&mail);
- virtual void deleteMails(const QString & mailbox,QList<RecMail> &target);
+ virtual void deleteMails(const QString & FolderName,QList<RecMail> &target);
virtual int deleteAllMail(const Folder*);
virtual const QString&getType()const;
+ virtual const QString&getName()const;
protected:
static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
QString MBOXPath;
+ QString MBOXName;
static const QString wrapperType;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index cceb22e..67bde38 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -107,8 +107,9 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
}
void POP3wrapper::login()
{
+ if (account->getOffline()) return;
/* we'll hold the line */
if ( m_pop3 != NULL ) return;
const char *server, *user, *pass;
@@ -248,4 +249,9 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail)
const QString&POP3wrapper::getType()const
{
return account->getType();
}
+
+const QString&POP3wrapper::getName()const
+{
+ return account->getAccountName();
+}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index f0307b6..d2b708d 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -29,8 +29,9 @@ public:
virtual RecBody fetchBody( const RecMail &mail );
virtual encodedString* fetchRawBody(const RecMail&mail);
virtual void logout();
virtual const QString&getType()const;
+ virtual const QString&getName()const;
static void pop3_progress( size_t current, size_t maximum );
protected:
void login();
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp
index c5187f5..02a80a3 100644
--- a/noncore/net/mail/libmailwrapper/settings.cpp
+++ b/noncore/net/mail/libmailwrapper/settings.cpp
@@ -167,8 +167,10 @@ void IMAPaccount::read()
password = conf->readEntryCrypt( "Password","" );
if (password.isNull()) password = "";
prefix = conf->readEntry("MailPrefix","");
if (prefix.isNull()) prefix = "";
+ offline = conf->readBoolEntry("Offline",false);
+ delete conf;
}
void IMAPaccount::save()
{
@@ -183,9 +185,11 @@ void IMAPaccount::save()
conf->writeEntry( "SSL", ssl );
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
conf->writeEntry( "MailPrefix",prefix);
+ conf->writeEntry( "Offline",offline);
conf->write();
+ delete conf;
}
QString IMAPaccount::getFileName()
@@ -237,8 +241,10 @@ void POP3account::read()
port = conf->readEntry( "Port" );
ssl = conf->readBoolEntry( "SSL" );
user = conf->readEntry( "User" );
password = conf->readEntryCrypt( "Password" );
+ offline = conf->readBoolEntry("Offline",false);
+ delete conf;
}
void POP3account::save()
{
@@ -252,9 +258,11 @@ void POP3account::save()
conf->writeEntry( "Port", port );
conf->writeEntry( "SSL", ssl );
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
+ conf->writeEntry( "Offline",offline);
conf->write();
+ delete conf;
}
QString POP3account::getFileName()
@@ -312,8 +320,9 @@ void SMTPaccount::read()
ssl = conf->readBoolEntry( "SSL" );
login = conf->readBoolEntry( "Login" );
user = conf->readEntry( "User" );
password = conf->readEntryCrypt( "Password" );
+ delete conf;
}
void SMTPaccount::save()
{
@@ -329,8 +338,9 @@ void SMTPaccount::save()
conf->writeEntry( "Login", login );
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
conf->write();
+ delete conf;
}
QString SMTPaccount::getFileName()
@@ -385,8 +395,9 @@ void NNTPaccount::read()
ssl = conf->readBoolEntry( "SSL" );
login = conf->readBoolEntry( "Login" );
user = conf->readEntry( "User" );
password = conf->readEntryCrypt( "Password" );
+ delete conf;
}
void NNTPaccount::save()
{
@@ -402,8 +413,9 @@ void NNTPaccount::save()
conf->writeEntry( "Login", login );
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
conf->write();
+ delete conf;
}
QString NNTPaccount::getFileName()
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h
index caa5dfc..2104997 100644
--- a/noncore/net/mail/libmailwrapper/settings.h
+++ b/noncore/net/mail/libmailwrapper/settings.h
@@ -29,17 +29,20 @@ public:
const QString&getPassword()const { return password; }
void setSSL( bool b ) { ssl = b; }
bool getSSL() { return ssl; }
+
+ void setOffline(bool b) {offline = b;}
+ bool getOffline()const{return offline;}
virtual QString getFileName() { return accountName; }
virtual void read() { qDebug( "base reading..." ); }
virtual void save() { qDebug( "base saving..." ); }
protected:
QString accountName, type, server, port, user, password;
bool ssl;
-
+ bool offline;
};
class IMAPaccount : public Account
{
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index 4764b77..281b88e 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -488,9 +488,9 @@ void SMTPwrapper::progress( size_t current, size_t maximum )
void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box)
{
if (!mail) return;
QString localfolders = AbstractMail::defaultLocalfolder();
- MBOXwrapper*wrap = new MBOXwrapper(localfolders);
+ AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
wrap->storeMessage(mail,length,box);
delete wrap;
}
@@ -515,13 +515,11 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
if (data) free(data);
qDebug("Error fetching mime...");
return;
}
- QString tmp = data;
- tmp.replace(QRegExp("\r+",true,false),"");
msg = 0;
if (later) {
- storeMail((char*)tmp.data(),tmp.length(),"Outgoing");
+ storeMail(data,size,"Outgoing");
if (data) free( data );
Config cfg( "mail" );
cfg.setGroup( "Status" );
cfg.writeEntry( "outgoing", ++m_queuedMail );
@@ -635,9 +633,9 @@ void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later )
mailmime_free( mimeMail );
}
}
-int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
+int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which)
{
size_t curTok = 0;
mailimf_fields *fields = 0;
mailimf_field*ffrom = 0;
@@ -684,9 +682,9 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
if (!smtp) return false;
QString localfolders = AbstractMail::defaultLocalfolder();
- MBOXwrapper*wrap = new MBOXwrapper(localfolders);
+ AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
if (!wrap) {
qDebug("memory error");
return false;
}
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index 04fc4b0..7dcdbfd 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -9,9 +9,9 @@
#include "settings.h"
class Mail;
-class MBOXwrapper;
+class AbstractMail;
class RecMail;
class Attachment;
struct mailimf_fields;
struct mailimf_field;
@@ -58,9 +58,9 @@ protected:
void storeMail(mailmime*mail, const QString&box);
Settings *settings;
- int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which);
+ int sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which);
int m_queuedMail;
static const char* USER_AGENT;
diff --git a/noncore/net/mail/selectstore.cpp b/noncore/net/mail/selectstore.cpp
index 28ab5a8..0a07d51 100644
--- a/noncore/net/mail/selectstore.cpp
+++ b/noncore/net/mail/selectstore.cpp
@@ -1,19 +1,70 @@
#include "selectstore.h"
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <libmailwrapper/abstractmail.h>
Selectstore::Selectstore(QWidget* parent, const char* name)
:selectstoreui(parent,name,true)
{
-
+ folderMap.clear();
+ mailMap.clear();
+ cMail = 0;
}
Selectstore::~Selectstore()
{
}
void Selectstore::slotCreateNewFolder()
{
+ bool how = newFoldersel->isChecked();
+ folderSelection->setEnabled(!how);
+ newFolderedit->setEnabled(how);
}
void Selectstore::slotMoveMail()
{
}
+
+void Selectstore::addAccounts(AbstractMail*mail,const QStringList&folders)
+{
+ accountSelection->insertItem(mail->getName());
+ mailMap[accountSelection->count()-1]=mail;
+ folderMap[accountSelection->count()-1]=folders;
+ if (accountSelection->count()==1) {
+ cMail = mail;
+ folderSelection->insertStringList(folders);
+ }
+}
+
+void Selectstore::slotAccountselected(int i)
+{
+ folderSelection->clear();
+ folderSelection->insertStringList(folderMap[i]);
+ cMail = mailMap[i];
+}
+
+QString Selectstore::currentFolder()
+{
+ if (newFoldersel->isChecked()) {
+ return newFolderedit->text();
+ } else {
+ return folderSelection->currentText();
+ }
+}
+
+AbstractMail*Selectstore::currentMail()
+{
+ return cMail;
+}
+
+bool Selectstore::newFolder()
+{
+ return newFoldersel->isChecked();
+}
+
+bool Selectstore::moveMails()
+{
+ return selMove->isChecked();
+}
diff --git a/noncore/net/mail/selectstore.h b/noncore/net/mail/selectstore.h
index 8b8e8ee..447a6ae 100644
--- a/noncore/net/mail/selectstore.h
+++ b/noncore/net/mail/selectstore.h
@@ -1,19 +1,33 @@
#ifndef _SELECTSTORE_H
#define _SELECTSTORE_H
#include "selectstoreui.h"
+#include <qvaluelist.h>
+#include <qmap.h>
+#include <qstringlist.h>
+
+class AbstractMail;
class Selectstore:public selectstoreui
{
Q_OBJECT
public:
Selectstore(QWidget* parent = 0, const char* name = 0);
virtual ~Selectstore();
+ virtual void addAccounts(AbstractMail*mail,const QStringList&folders);
+ virtual QString currentFolder();
+ virtual AbstractMail*currentMail();
+ bool newFolder();
+ bool moveMails();
-protected:
+protected slots:
virtual void slotCreateNewFolder();
virtual void slotMoveMail();
-protected slots:
+ virtual void slotAccountselected(int);
+protected:
+ QMap<int,QStringList> folderMap;
+ QMap<int,AbstractMail*> mailMap;
+ AbstractMail*cMail;
};
#endif
diff --git a/noncore/net/mail/selectstoreui.ui b/noncore/net/mail/selectstoreui.ui
index 3741b71..5f0e507 100644
--- a/noncore/net/mail/selectstoreui.ui
+++ b/noncore/net/mail/selectstoreui.ui
@@ -10,9 +10,9 @@
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>190</width>
+ <width>182</width>
<height>273</height>
</rect>
</property>
<property stdset="1">
@@ -27,13 +27,13 @@
</property>
<vbox>
<property stdset="1">
<name>margin</name>
- <number>2</number>
+ <number>1</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>2</number>
+ <number>1</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
@@ -173,8 +173,29 @@
<bool>false</bool>
</property>
</widget>
<widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>newFolderLabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Prefix will prepend, no need to enter it!</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>WordBreak|AlignCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ <property>
+ <name>wordwrap</name>
+ </property>
+ </widget>
+ <widget>
<class>Line</class>
<property stdset="1">
<name>name</name>
<cstring>Line2</cstring>
@@ -230,10 +251,24 @@
<signal>clicked()</signal>
<receiver>selectstoreui</receiver>
<slot>slotCreateNewFolder()</slot>
</connection>
- <slot access="protected">slotMoveMail()</slot>
+ <connection>
+ <sender>accountSelection</sender>
+ <signal>activated(int)</signal>
+ <receiver>selectstoreui</receiver>
+ <slot>slotAccountselected(int)</slot>
+ </connection>
+ <connection>
+ <sender>folderSelection</sender>
+ <signal>activated(int)</signal>
+ <receiver>selectstoreui</receiver>
+ <slot>slotFolderSelected(int)</slot>
+ </connection>
+ <slot access="protected">slotFolderSelected(int)</slot>
+ <slot access="protected">slotAccountselected(int)</slot>
<slot access="protected">slotCreateNewFolder()</slot>
+ <slot access="protected">slotMoveMail()</slot>
</connections>
<tabstops>
<tabstop>accountSelection</tabstop>
<tabstop>folderSelection</tabstop>