summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.cpp4
-rw-r--r--noncore/net/mail/abstractmail.h4
-rw-r--r--noncore/net/mail/imapwrapper.cpp40
-rw-r--r--noncore/net/mail/imapwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h4
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp40
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h7
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp21
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp11
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h2
-rw-r--r--noncore/net/mail/mailtypes.h7
-rw-r--r--noncore/net/mail/mboxwrapper.cpp21
-rw-r--r--noncore/net/mail/mboxwrapper.h1
-rw-r--r--noncore/net/mail/pop3wrapper.cpp11
-rw-r--r--noncore/net/mail/pop3wrapper.h2
18 files changed, 180 insertions, 2 deletions
diff --git a/noncore/net/mail/abstractmail.cpp b/noncore/net/mail/abstractmail.cpp
index 416795b..f303d72 100644
--- a/noncore/net/mail/abstractmail.cpp
+++ b/noncore/net/mail/abstractmail.cpp
@@ -85,6 +85,10 @@ QString AbstractMail::gen_attachment_id()
QTextStream stream(&file);
return "{" + stream.read().stripWhiteSpace() + "}";
}
+int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool)
+{
+ return 0;
+}
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h
index 5dc4cab..dab9e10 100644
--- a/noncore/net/mail/abstractmail.h
+++ b/noncore/net/mail/abstractmail.h
@@ -8,21 +8,23 @@ 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 void deleteMail(const RecMail&mail)=0;
@@ -33,13 +35,13 @@ public:
/* 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){return 0;}
+ virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
/* mbox only! */
static AbstractMail* getWrapper(const QString&a);
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index b437df0..f1d42c2 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -931,6 +931,46 @@ int IMAPwrapper::deleteMbox(const Folder*folder)
if (res != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("%1").arg(m_imap->imap_response));
return 0;
}
return 1;
}
+
+void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
+{
+ mailimap_status_att_list * att_list =0;
+ mailimap_mailbox_data_status * status=0;
+ clistiter * cur = 0;
+ int r = 0;
+ int res = 0;
+ target_stat.message_count = 0;
+ target_stat.message_unseen = 0;
+ target_stat.message_recent = 0;
+ login();
+ if (!m_imap) {
+ return;
+ }
+ att_list = mailimap_status_att_list_new_empty();
+ if (!att_list) return;
+ r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES);
+ r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT);
+ r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
+ r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
+ for (cur = clist_begin(status->st_info_list);
+ cur != NULL ; cur = clist_next(cur)) {
+ mailimap_status_info * status_info;
+ status_info = (mailimap_status_info *)clist_content(cur);
+ switch (status_info->st_att) {
+ case MAILIMAP_STATUS_ATT_MESSAGES:
+ target_stat.message_count = status_info->st_value;
+ break;
+ case MAILIMAP_STATUS_ATT_RECENT:
+ target_stat.message_recent = status_info->st_value;
+ break;
+ case MAILIMAP_STATUS_ATT_UNSEEN:
+ target_stat.message_unseen = status_info->st_value;
+ break;
+ }
+ }
+ mailimap_mailbox_data_status_free(status);
+ mailimap_status_att_list_free(att_list);
+}
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h
index 7941046..8f5a2b5 100644
--- a/noncore/net/mail/imapwrapper.h
+++ b/noncore/net/mail/imapwrapper.h
@@ -22,12 +22,13 @@ 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 RecBody fetchBody(const RecMail&mail);
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 416795b..f303d72 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -85,6 +85,10 @@ QString AbstractMail::gen_attachment_id()
QTextStream stream(&file);
return "{" + stream.read().stripWhiteSpace() + "}";
}
+int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool)
+{
+ return 0;
+}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 5dc4cab..dab9e10 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -8,21 +8,23 @@ 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 void deleteMail(const RecMail&mail)=0;
@@ -33,13 +35,13 @@ public:
/* 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){return 0;}
+ virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
/* mbox only! */
static AbstractMail* getWrapper(const QString&a);
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index b437df0..f1d42c2 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -931,6 +931,46 @@ int IMAPwrapper::deleteMbox(const Folder*folder)
if (res != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("%1").arg(m_imap->imap_response));
return 0;
}
return 1;
}
+
+void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
+{
+ mailimap_status_att_list * att_list =0;
+ mailimap_mailbox_data_status * status=0;
+ clistiter * cur = 0;
+ int r = 0;
+ int res = 0;
+ target_stat.message_count = 0;
+ target_stat.message_unseen = 0;
+ target_stat.message_recent = 0;
+ login();
+ if (!m_imap) {
+ return;
+ }
+ att_list = mailimap_status_att_list_new_empty();
+ if (!att_list) return;
+ r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES);
+ r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT);
+ r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
+ r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
+ for (cur = clist_begin(status->st_info_list);
+ cur != NULL ; cur = clist_next(cur)) {
+ mailimap_status_info * status_info;
+ status_info = (mailimap_status_info *)clist_content(cur);
+ switch (status_info->st_att) {
+ case MAILIMAP_STATUS_ATT_MESSAGES:
+ target_stat.message_count = status_info->st_value;
+ break;
+ case MAILIMAP_STATUS_ATT_RECENT:
+ target_stat.message_recent = status_info->st_value;
+ break;
+ case MAILIMAP_STATUS_ATT_UNSEEN:
+ target_stat.message_unseen = status_info->st_value;
+ break;
+ }
+ }
+ mailimap_mailbox_data_status_free(status);
+ mailimap_status_att_list_free(att_list);
+}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 7941046..8f5a2b5 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -22,12 +22,13 @@ 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 RecBody fetchBody(const RecMail&mail);
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index abfbe65..05c4816 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -179,7 +179,14 @@ protected:
void init();
void copy_old(const encodedString&old);
void clean();
};
+struct folderStat
+{
+ unsigned int message_count;
+ unsigned int message_unseen;
+ unsigned int message_recent;
+};
+
#endif
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 0aa33dd..540a971 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -298,6 +298,27 @@ int MBOXwrapper::deleteMbox(const Folder*tfolder)
Global::statusMessage(tr("Error deleting Mailbox."));
return 0;
}
return 1;
}
+void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
+{
+ mailfolder*folder = 0;
+ mailstorage*storage = mailstorage_new(NULL);
+ target_stat.message_count = 0;
+ target_stat.message_unseen = 0;
+ target_stat.message_recent = 0;
+ QString p = MBOXPath+"/"+mailbox;
+ QFile fi(p);
+ if (!fi.exists()) {
+ Global::statusMessage(tr("Mailbox doesn't exist."));
+ return;
+ }
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
+ r = mailfolder_connect(folder);
+ r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count,
+ &target_stat.message_recent,&target_stat.message_unseen);
+ if (folder) mailfolder_free(folder);
+ if (storage) mailstorage_free(storage);
+}
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index 226a544..f822997 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -14,12 +14,13 @@ class MBOXwrapper : public Genericwrapper
public:
MBOXwrapper(const QString & dir);
virtual ~MBOXwrapper();
virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
virtual QList<Folder>* listFolders();
+ virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
virtual int deleteMbox(const Folder*);
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index de90dd1..d76d82a 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -213,6 +213,17 @@ int POP3wrapper::deleteAllMail(const Folder*)
res=0;
}
break;
}
return res;
}
+
+void POP3wrapper::statusFolder(folderStat&target_stat,const QString&)
+{
+ login();
+ target_stat.message_count = 0;
+ target_stat.message_unseen = 0;
+ target_stat.message_recent = 0;
+ if (!m_pop3) return;
+ int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count,
+ &target_stat.message_recent,&target_stat.message_unseen);
+}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index b3a42be..536cadc 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -15,12 +15,14 @@ class POP3wrapper : public Genericwrapper
public:
POP3wrapper( POP3account *a );
virtual ~POP3wrapper();
/* mailbox will be ignored */
virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
virtual QList<Folder>* listFolders();
+ /* mailbox will be ignored */
+ 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*);
virtual RecBody fetchBody( const RecMail &mail );
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h
index abfbe65..05c4816 100644
--- a/noncore/net/mail/mailtypes.h
+++ b/noncore/net/mail/mailtypes.h
@@ -179,7 +179,14 @@ protected:
void init();
void copy_old(const encodedString&old);
void clean();
};
+struct folderStat
+{
+ unsigned int message_count;
+ unsigned int message_unseen;
+ unsigned int message_recent;
+};
+
#endif
diff --git a/noncore/net/mail/mboxwrapper.cpp b/noncore/net/mail/mboxwrapper.cpp
index 0aa33dd..540a971 100644
--- a/noncore/net/mail/mboxwrapper.cpp
+++ b/noncore/net/mail/mboxwrapper.cpp
@@ -298,6 +298,27 @@ int MBOXwrapper::deleteMbox(const Folder*tfolder)
Global::statusMessage(tr("Error deleting Mailbox."));
return 0;
}
return 1;
}
+void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
+{
+ mailfolder*folder = 0;
+ mailstorage*storage = mailstorage_new(NULL);
+ target_stat.message_count = 0;
+ target_stat.message_unseen = 0;
+ target_stat.message_recent = 0;
+ QString p = MBOXPath+"/"+mailbox;
+ QFile fi(p);
+ if (!fi.exists()) {
+ Global::statusMessage(tr("Mailbox doesn't exist."));
+ return;
+ }
+ int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
+ folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
+ r = mailfolder_connect(folder);
+ r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count,
+ &target_stat.message_recent,&target_stat.message_unseen);
+ if (folder) mailfolder_free(folder);
+ if (storage) mailstorage_free(storage);
+}
diff --git a/noncore/net/mail/mboxwrapper.h b/noncore/net/mail/mboxwrapper.h
index 226a544..f822997 100644
--- a/noncore/net/mail/mboxwrapper.h
+++ b/noncore/net/mail/mboxwrapper.h
@@ -14,12 +14,13 @@ class MBOXwrapper : public Genericwrapper
public:
MBOXwrapper(const QString & dir);
virtual ~MBOXwrapper();
virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
virtual QList<Folder>* listFolders();
+ virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
virtual int deleteMbox(const Folder*);
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index de90dd1..d76d82a 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -213,6 +213,17 @@ int POP3wrapper::deleteAllMail(const Folder*)
res=0;
}
break;
}
return res;
}
+
+void POP3wrapper::statusFolder(folderStat&target_stat,const QString&)
+{
+ login();
+ target_stat.message_count = 0;
+ target_stat.message_unseen = 0;
+ target_stat.message_recent = 0;
+ if (!m_pop3) return;
+ int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count,
+ &target_stat.message_recent,&target_stat.message_unseen);
+}
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index b3a42be..536cadc 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -15,12 +15,14 @@ class POP3wrapper : public Genericwrapper
public:
POP3wrapper( POP3account *a );
virtual ~POP3wrapper();
/* mailbox will be ignored */
virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
virtual QList<Folder>* listFolders();
+ /* mailbox will be ignored */
+ 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*);
virtual RecBody fetchBody( const RecMail &mail );