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
@@ -10,7 +10,7 @@
/**
* POP3 Account stuff
*/
-POP3viewItem::POP3viewItem( POP3account *a, QListView *parent )
+POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
: AccountViewItem( parent )
{
account = a;
@@ -32,6 +32,7 @@ AbstractMail *POP3viewItem::getWrapper()
void POP3viewItem::refresh( QList<RecMail> & )
{
+ if (account->getOffline()) return;
QList<Folder> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child ) {
@@ -56,6 +57,52 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail )
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;
@@ -91,16 +138,16 @@ QPopupMenu * POP3folderItem::getContextMenu()
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)
@@ -126,7 +173,7 @@ void POP3folderItem::contextMenuSelected(int which)
/**
* IMAP Account stuff
*/
-IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
+IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
: AccountViewItem( parent )
{
account = a;
@@ -183,12 +230,18 @@ 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;
@@ -209,6 +262,7 @@ 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);
@@ -231,10 +285,15 @@ 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;
}
@@ -271,6 +330,15 @@ void IMAPviewItem::contextMenuSelected(int id)
removeChilds();
wrapper->logout();
break;
+ case 3:
+ if (account->getOffline()==false) {
+ removeChilds();
+ wrapper->logout();
+ }
+ account->setOffline(!account->getOffline());
+ account->save();
+ refreshFolders(false);
+ break;
default:
break;
}
@@ -281,9 +349,9 @@ 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 )
@@ -312,6 +380,11 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi
setText( 0, folder->getDisplayName() );
}
+IMAPfolderItem::~IMAPfolderItem()
+{
+ delete folder;
+}
+
const QString& IMAPfolderItem::Delemiter()const
{
return folder->Separator();
@@ -342,6 +415,7 @@ QPopupMenu * IMAPfolderItem::getContextMenu()
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) {
@@ -389,6 +463,13 @@ 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);
@@ -406,6 +487,9 @@ void IMAPfolderItem::contextMenuSelected(int id)
case 3:
deleteFolder();
break;
+ case 4:
+ downloadMails();
+ break;
default:
break;
}
@@ -417,6 +501,33 @@ 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;
@@ -447,6 +558,12 @@ 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());
@@ -471,17 +588,21 @@ 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 );
}
}
@@ -503,12 +624,12 @@ 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()
@@ -524,15 +645,62 @@ RecBody AccountView::fetchBody(const RecMail&aMail)
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 );
@@ -602,6 +770,19 @@ 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) {
@@ -636,6 +817,11 @@ 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())
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
@@ -12,36 +12,45 @@ 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
@@ -49,7 +58,7 @@ 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();
@@ -57,8 +66,6 @@ public:
protected:
void downloadMails();
-
-private:
Folder *folder;
POP3viewItem *pop3;
};
@@ -69,23 +76,24 @@ 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
@@ -94,7 +102,7 @@ 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;
@@ -104,8 +112,7 @@ public:
protected:
virtual void createNewFolder();
virtual void deleteFolder();
-
-private:
+ virtual void downloadMails();
Folder *folder;
IMAPviewItem *imap;
};
@@ -115,21 +122,18 @@ 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;
@@ -140,15 +144,15 @@ 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;
};
@@ -159,8 +163,10 @@ class AccountView : public QListView
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();
@@ -168,12 +174,15 @@ public slots:
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
@@ -21,9 +21,9 @@ 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)
@@ -99,3 +99,8 @@ QString AbstractMail::defaultLocalfolder()
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
@@ -31,6 +31,7 @@ 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;
@@ -46,11 +47,12 @@ 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);
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
@@ -29,6 +29,7 @@ void IMAPwrapper::login()
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) {
@@ -1006,6 +1007,11 @@ const QString&IMAPwrapper::getType()const
return account->getType();
}
+const QString&IMAPwrapper::getName()const
+{
+ return account->getAccountName();
+}
+
encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
{
// dummy
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
@@ -45,6 +45,8 @@ public:
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
@@ -8,8 +8,8 @@
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()) {
@@ -330,3 +330,8 @@ 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
@@ -13,7 +13,7 @@ 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 );
@@ -32,13 +32,15 @@ public:
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;
};
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
@@ -108,6 +108,7 @@ 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;
@@ -249,3 +250,8 @@ 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
@@ -30,6 +30,7 @@ public:
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:
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
@@ -168,6 +168,8 @@ void IMAPaccount::read()
if (password.isNull()) password = "";
prefix = conf->readEntry("MailPrefix","");
if (prefix.isNull()) prefix = "";
+ offline = conf->readBoolEntry("Offline",false);
+ delete conf;
}
void IMAPaccount::save()
@@ -184,7 +186,9 @@ void IMAPaccount::save()
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
conf->writeEntry( "MailPrefix",prefix);
+ conf->writeEntry( "Offline",offline);
conf->write();
+ delete conf;
}
@@ -238,6 +242,8 @@ void POP3account::read()
ssl = conf->readBoolEntry( "SSL" );
user = conf->readEntry( "User" );
password = conf->readEntryCrypt( "Password" );
+ offline = conf->readBoolEntry("Offline",false);
+ delete conf;
}
void POP3account::save()
@@ -253,7 +259,9 @@ void POP3account::save()
conf->writeEntry( "SSL", ssl );
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
+ conf->writeEntry( "Offline",offline);
conf->write();
+ delete conf;
}
@@ -313,6 +321,7 @@ void SMTPaccount::read()
login = conf->readBoolEntry( "Login" );
user = conf->readEntry( "User" );
password = conf->readEntryCrypt( "Password" );
+ delete conf;
}
void SMTPaccount::save()
@@ -330,6 +339,7 @@ void SMTPaccount::save()
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
conf->write();
+ delete conf;
}
@@ -386,6 +396,7 @@ void NNTPaccount::read()
login = conf->readBoolEntry( "Login" );
user = conf->readEntry( "User" );
password = conf->readEntryCrypt( "Password" );
+ delete conf;
}
void NNTPaccount::save()
@@ -403,6 +414,7 @@ void NNTPaccount::save()
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
conf->write();
+ delete conf;
}
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
@@ -30,6 +30,9 @@ public:
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..." ); }
@@ -38,7 +41,7 @@ public:
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
@@ -489,7 +489,7 @@ 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;
}
@@ -516,11 +516,9 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
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" );
@@ -636,7 +634,7 @@ void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later )
}
}
-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;
@@ -685,7 +683,7 @@ 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
@@ -10,7 +10,7 @@
#include "settings.h"
class Mail;
-class MBOXwrapper;
+class AbstractMail;
class RecMail;
class Attachment;
struct mailimf_fields;
@@ -59,7 +59,7 @@ 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,9 +1,15 @@
#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()
@@ -12,8 +18,53 @@ 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
@@ -2,6 +2,11 @@
#define _SELECTSTORE_H
#include "selectstoreui.h"
+#include <qvaluelist.h>
+#include <qmap.h>
+#include <qstringlist.h>
+
+class AbstractMail;
class Selectstore:public selectstoreui
{
@@ -9,11 +14,20 @@ class Selectstore:public selectstoreui
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
@@ -11,7 +11,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>190</width>
+ <width>182</width>
<height>273</height>
</rect>
</property>
@@ -28,11 +28,11 @@
<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>
@@ -174,6 +174,27 @@
</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>
@@ -231,8 +252,22 @@
<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>