summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-04 16:33:39 (UTC)
committer alwin <alwin>2004-01-04 16:33:39 (UTC)
commit6ee1d5d35243f611e0a848d454bfa309b8de0fc9 (patch) (side-by-side diff)
treea07cc2d85da3df79904f363da262834f64b64736
parent59fee003137f5fd7782e3a42159e53424d100e67 (diff)
downloadopie-6ee1d5d35243f611e0a848d454bfa309b8de0fc9.zip
opie-6ee1d5d35243f611e0a848d454bfa309b8de0fc9.tar.gz
opie-6ee1d5d35243f611e0a848d454bfa309b8de0fc9.tar.bz2
- added start of status class
- unification of (public) mailwrapper interfaces - preparition for message store/transfer
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h8
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp15
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/libmailwrapper.pro6
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp8
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h4
7 files changed, 38 insertions, 9 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index ca9caed..a070fb0 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -16,40 +16,42 @@ 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;
virtual void answeredMail(const RecMail&mail)=0;
- virtual void cleanMimeCache(){};
- virtual int deleteAllMail(const Folder*){return 1;}
- virtual int deleteMbox(const Folder*){return 1;}
+ virtual int deleteAllMail(const Folder*)=0;
+ virtual int deleteMbox(const Folder*)=0;
+ virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
+ virtual void cleanMimeCache(){};
/* mail box methods */
/* parameter is the box to create.
* if the implementing subclass has prefixes,
* them has to be appended automatic.
*/
virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
+ virtual void logout()=0;
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
/* mbox only! */
static AbstractMail* getWrapper(const QString&a);
static QString defaultLocalfolder();
protected:
static encodedString*decode_String(const encodedString*text,const QString&enc);
static QString convert_String(const char*text);
static QString gen_attachment_id();
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index 32b75c8..1d65c0a 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -22,32 +22,35 @@ struct mailsession;
/* this class hold just the funs shared between
* mbox and pop3 (later mh, too) mail access.
* it is not desigend to make a instance of it!
*/
class Genericwrapper : public AbstractMail
{
Q_OBJECT
public:
Genericwrapper();
virtual ~Genericwrapper();
virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
virtual void cleanMimeCache();
+ virtual int deleteMbox(const Folder*){return 1;}
+ virtual void logout(){};
+ virtual void storeMessage(const char*msg,size_t length, const QString&folder){};
protected:
RecMail *parseHeader( const char *header );
RecBody parseMail( mailmessage * msg );
QString parseMailboxList( mailimf_mailbox_list *list );
QString parseMailbox( mailimf_mailbox *box );
QString parseGroup( mailimf_group *group );
QString parseAddressList( mailimf_address_list *list );
QString parseDateTime( mailimf_date_time *date );
void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
static void fillParameters(RecPart&target,clist*parameters);
static QString getencoding(mailmime_mechanism*aEnc);
virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox);
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index f1d42c2..0c1e05e 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -34,34 +34,34 @@ void IMAPwrapper::login()
if (m_imap) {
err = mailimap_noop(m_imap);
if (err!=MAILIMAP_NO_ERROR) {
logout();
} else {
mailstream_flush(m_imap->imap_stream);
return;
}
}
server = account->getServer().latin1();
port = account->getPort().toUInt();
if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
- user = strdup( login.getUser().latin1() );
- pass = strdup( login.getPassword().latin1() );
+ user = login.getUser().latin1();
+ pass = login.getPassword().latin1();
} else {
// cancel
qDebug( "IMAP: Login canceled" );
return;
}
} else {
user = account->getUser().latin1();
pass = account->getPassword().latin1();
}
m_imap = mailimap_new( 20, &imap_progress );
/* connect */
if (account->getSSL()) {
err = mailimap_ssl_connect( m_imap, (char*)server, port );
} else {
@@ -961,16 +961,27 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
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);
}
+
+void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
+{
+ login();
+ if (!m_imap) return;
+ if (!msg) return;
+ int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length);
+ if (r != MAILIMAP_NO_ERROR) {
+ Global::statusMessage("Error storing mail!");
+ }
+}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 8f5a2b5..a97f12d 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -17,47 +17,48 @@ struct mailimap_body_fields;
struct mailimap_msg_att;
class encodedString;
class IMAPwrapper : public AbstractMail
{
Q_OBJECT
public:
IMAPwrapper( IMAPaccount *a );
virtual ~IMAPwrapper();
virtual QList<Folder>* listFolders();
virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
virtual int deleteAllMail(const Folder*folder);
+ virtual void storeMessage(const char*msg,size_t length, const QString&folder);
virtual RecBody fetchBody(const RecMail&mail);
virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
virtual int deleteMbox(const Folder*folder);
static void imap_progress( size_t current, size_t maximum );
+ virtual void logout();
protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
- void logout();
virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
/* just helpers */
static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.pro b/noncore/net/mail/libmailwrapper/libmailwrapper.pro
index 4b4a4f1..18583bb 100644
--- a/noncore/net/mail/libmailwrapper/libmailwrapper.pro
+++ b/noncore/net/mail/libmailwrapper/libmailwrapper.pro
@@ -1,42 +1,44 @@
TEMPLATE = lib
CONFIG += qt warn_on debug
HEADERS = mailwrapper.h \
imapwrapper.h \
mailtypes.h \
pop3wrapper.h \
abstractmail.h \
smtpwrapper.h \
genericwrapper.h \
mboxwrapper.h \
settings.h \
logindialog.h \
- sendmailprogress.h
+ sendmailprogress.h \
+ statusmail.h
SOURCES = imapwrapper.cpp \
mailwrapper.cpp \
mailtypes.cpp \
pop3wrapper.cpp \
abstractmail.cpp \
smtpwrapper.cpp \
genericwrapper.cpp \
mboxwrapper.cpp \
settings.cpp \
logindialog.cpp \
- sendmailprogress.cpp
+ sendmailprogress.cpp \
+ statusmail.cpp
INTERFACES = logindialogui.ui \
sendmailprogressui.ui
INCLUDEPATH += $(OPIEDIR)/include
CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
contains( CONFTEST, y ){
LIBS += -lqpe -letpan -lssl -lcrypto -liconv
}else{
LIBS += -lqpe -letpan -lssl -lcrypto
}
DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
TARGET = mailwrapper
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index d76d82a..b4eca6f 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -214,16 +214,24 @@ int POP3wrapper::deleteAllMail(const Folder*)
}
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);
}
+
+void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
+{
+ mailmessage * mailmsg = 0;
+ int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg);
+ err = mailmessage_fetch(mailmsg,target,length);
+ if (mailmsg) mailmessage_free(mailmsg);
+}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 536cadc..9cba101 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -13,27 +13,29 @@ class POP3wrapper : public Genericwrapper
Q_OBJECT
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 );
+ virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length);
+ virtual void logout();
+
static void pop3_progress( size_t current, size_t maximum );
protected:
void login();
- void logout();
POP3account *account;
mailstorage*m_pop3;
mailfolder*m_folder;
};
#endif