-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.h | 4 |
6 files changed, 32 insertions, 8 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index b253b49..0ce2c6c 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp @@ -171,69 +171,71 @@ QList<Folder>* IMAPwrapper::listFolders() list = (mailimap_mailbox_list *) current->data; // it is better use the deep copy mechanism of qt itself // instead of using strdup! temp = list->mb_name; folders->append( new IMAPFolder(temp)); current = current->next; } } else { qDebug("error fetching folders: %s",m_imap->imap_response); } mailimap_list_result_free( result ); /* * second stage - get the other then inbox folders */ mask = "*" ; path = account->getPrefix().latin1(); if (!path) path = ""; result = clist_new(); qDebug(path); bool selectable = true; mailimap_mbx_list_flags*bflags; err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); if ( err == MAILIMAP_NO_ERROR ) { current = result->first; for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { list = (mailimap_mailbox_list *) current->data; // it is better use the deep copy mechanism of qt itself // instead of using strdup! temp = list->mb_name; if (temp.lower()=="inbox") continue; + if (temp.lower()==account->getPrefix().lower()) + continue; if ( (bflags = list->mb_flag) ) { selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); } - folders->append(new IMAPFolder(temp,selectable)); + folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); } } else { qDebug("error fetching folders %s",m_imap->imap_response); } mailimap_list_result_free( result ); return folders; } RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) { RecMail * m = 0; mailimap_msg_att_item *item=0; clistcell *current,*c,*cf; mailimap_msg_att_dynamic*flist; mailimap_flag_fetch*cflag; int size; QBitArray mFlags(7); QStringList addresslist; if (!m_att) { return m; } m = new RecMail(); for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { current = c; size = 0; item = (mailimap_msg_att_item*)current->data; if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; if (!flist->att_list) { continue; } diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index b253b49..0ce2c6c 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -171,69 +171,71 @@ QList<Folder>* IMAPwrapper::listFolders() list = (mailimap_mailbox_list *) current->data; // it is better use the deep copy mechanism of qt itself // instead of using strdup! temp = list->mb_name; folders->append( new IMAPFolder(temp)); current = current->next; } } else { qDebug("error fetching folders: %s",m_imap->imap_response); } mailimap_list_result_free( result ); /* * second stage - get the other then inbox folders */ mask = "*" ; path = account->getPrefix().latin1(); if (!path) path = ""; result = clist_new(); qDebug(path); bool selectable = true; mailimap_mbx_list_flags*bflags; err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); if ( err == MAILIMAP_NO_ERROR ) { current = result->first; for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { list = (mailimap_mailbox_list *) current->data; // it is better use the deep copy mechanism of qt itself // instead of using strdup! temp = list->mb_name; if (temp.lower()=="inbox") continue; + if (temp.lower()==account->getPrefix().lower()) + continue; if ( (bflags = list->mb_flag) ) { selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); } - folders->append(new IMAPFolder(temp,selectable)); + folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); } } else { qDebug("error fetching folders %s",m_imap->imap_response); } mailimap_list_result_free( result ); return folders; } RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) { RecMail * m = 0; mailimap_msg_att_item *item=0; clistcell *current,*c,*cf; mailimap_msg_att_dynamic*flist; mailimap_flag_fetch*cflag; int size; QBitArray mFlags(7); QStringList addresslist; if (!m_att) { return m; } m = new RecMail(); for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { current = c; size = 0; item = (mailimap_msg_att_item*)current->data; if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; if (!flist->att_list) { continue; } diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 3ffc274..96602c2 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp @@ -5,68 +5,78 @@ #include <fcntl.h> #include <string.h> #include <qdir.h> #include "mailwrapper.h" #include "logindialog.h" //#include "mail.h" #include "defines.h" Attachment::Attachment( DocLnk lnk ) { doc = lnk; size = QFileInfo( doc.file() ).size(); } Folder::Folder(const QString&tmp_name ) { name = tmp_name; nameDisplay = name; for ( int pos = nameDisplay.find( '&' ); pos != -1; pos = nameDisplay.find( '&' ) ) { int end = nameDisplay.find( '-' ); if ( end == -1 || end <= pos ) break; QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); // TODO: do real base64 decoding here ! if ( str64.compare( "APw" ) == 0 ) { nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); } else if ( str64.compare( "APY" ) == 0 ) { nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); } } - qDebug( "folder " + name + " - displayed as " + nameDisplay ); } + +IMAPFolder::IMAPFolder(const QString&name,bool select,const QString&prefix ) + : Folder( name ),m_MaySelect(select) +{ + if (prefix.length()>0) { + if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { + nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); + } + } +} + MailWrapper::MailWrapper( Settings *s ) : QObject() { settings = s; } QString MailWrapper::mailsmtpError( int errnum ) { switch ( errnum ) { case MAILSMTP_NO_ERROR: return tr( "No error" ); case MAILSMTP_ERROR_UNEXPECTED_CODE: return tr( "Unexpected error code" ); case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: return tr( "Service not available" ); case MAILSMTP_ERROR_STREAM: return tr( "Stream error" ); case MAILSMTP_ERROR_HOSTNAME: return tr( "gethostname() failed" ); case MAILSMTP_ERROR_NOT_IMPLEMENTED: return tr( "Not implemented" ); case MAILSMTP_ERROR_ACTION_NOT_TAKEN: return tr( "Error, action not taken" ); case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: return tr( "Data exceeds storage allocation" ); case MAILSMTP_ERROR_IN_PROCESSING: return tr( "Error in processing" ); // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: // return tr( "Insufficient system storage" ); case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: return tr( "Mailbox unavailable" ); case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 34fd5c5..6994dd8 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h @@ -47,73 +47,73 @@ public: const QString&getName()const { return name; } void setName( QString s ) { name = s; } const QString&getMail()const{ return mail; } void setMail( const QString&s ) { mail = s; } const QString&getTo()const{ return to; } void setTo( const QString&s ) { to = s; } const QString&getCC()const{ return cc; } void setCC( const QString&s ) { cc = s; } const QString&getBCC()const { return bcc; } void setBCC( const QString&s ) { bcc = s; } const QString&getMessage()const { return message; } void setMessage( const QString&s ) { message = s; } const QString&getSubject()const { return subject; } void setSubject( const QString&s ) { subject = s; } const QString&getReply()const{ return reply; } void setReply( const QString&a ) { reply = a; } private: QList<Attachment> attList; QString name, mail, to, cc, bcc, reply, subject, message; }; class Folder : public QObject { Q_OBJECT public: Folder( const QString&init_name ); const QString&getDisplayName()const { return nameDisplay; } const QString&getName()const { return name; } virtual bool may_select()const{return true;}; -private: +protected: QString nameDisplay, name; }; class IMAPFolder : public Folder { public: - IMAPFolder( QString name,bool select=true ) : Folder( name ),m_MaySelect(select) {} + IMAPFolder(const QString&name,bool select=true,const QString&prefix="" ); virtual bool may_select()const{return m_MaySelect;} private: bool m_MaySelect; }; class MailWrapper : public QObject { Q_OBJECT public: MailWrapper( Settings *s ); void sendMail( Mail mail ); private: mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); mailimf_address_list *parseAddresses(const QString&addr ); mailimf_fields *createImfFields( Mail *mail ); mailmime *buildTxtPart( QString str ); mailmime *buildFilePart( QString filename, QString mimetype ); void addFileParts( mailmime *message, QList<Attachment> files ); mailmime *createMimeMail( Mail *mail ); void smtpSend( mailmime *mail ); mailimf_field *getField( mailimf_fields *fields, int type ); clist *createRcptList( mailimf_fields *fields ); char *getFrom( mailmime *mail ); SMTPaccount *getAccount( QString from ); void writeToFile( QString file, mailmime *mail ); void readFromFile( QString file, char **data, size_t *size ); static QString mailsmtpError( int err ); static QString getTmpFile(); Settings *settings; diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp index 3ffc274..96602c2 100644 --- a/noncore/net/mail/mailwrapper.cpp +++ b/noncore/net/mail/mailwrapper.cpp @@ -5,68 +5,78 @@ #include <fcntl.h> #include <string.h> #include <qdir.h> #include "mailwrapper.h" #include "logindialog.h" //#include "mail.h" #include "defines.h" Attachment::Attachment( DocLnk lnk ) { doc = lnk; size = QFileInfo( doc.file() ).size(); } Folder::Folder(const QString&tmp_name ) { name = tmp_name; nameDisplay = name; for ( int pos = nameDisplay.find( '&' ); pos != -1; pos = nameDisplay.find( '&' ) ) { int end = nameDisplay.find( '-' ); if ( end == -1 || end <= pos ) break; QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); // TODO: do real base64 decoding here ! if ( str64.compare( "APw" ) == 0 ) { nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); } else if ( str64.compare( "APY" ) == 0 ) { nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); } } - qDebug( "folder " + name + " - displayed as " + nameDisplay ); } + +IMAPFolder::IMAPFolder(const QString&name,bool select,const QString&prefix ) + : Folder( name ),m_MaySelect(select) +{ + if (prefix.length()>0) { + if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { + nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); + } + } +} + MailWrapper::MailWrapper( Settings *s ) : QObject() { settings = s; } QString MailWrapper::mailsmtpError( int errnum ) { switch ( errnum ) { case MAILSMTP_NO_ERROR: return tr( "No error" ); case MAILSMTP_ERROR_UNEXPECTED_CODE: return tr( "Unexpected error code" ); case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: return tr( "Service not available" ); case MAILSMTP_ERROR_STREAM: return tr( "Stream error" ); case MAILSMTP_ERROR_HOSTNAME: return tr( "gethostname() failed" ); case MAILSMTP_ERROR_NOT_IMPLEMENTED: return tr( "Not implemented" ); case MAILSMTP_ERROR_ACTION_NOT_TAKEN: return tr( "Error, action not taken" ); case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: return tr( "Data exceeds storage allocation" ); case MAILSMTP_ERROR_IN_PROCESSING: return tr( "Error in processing" ); // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: // return tr( "Insufficient system storage" ); case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: return tr( "Mailbox unavailable" ); case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h index 34fd5c5..6994dd8 100644 --- a/noncore/net/mail/mailwrapper.h +++ b/noncore/net/mail/mailwrapper.h @@ -47,73 +47,73 @@ public: const QString&getName()const { return name; } void setName( QString s ) { name = s; } const QString&getMail()const{ return mail; } void setMail( const QString&s ) { mail = s; } const QString&getTo()const{ return to; } void setTo( const QString&s ) { to = s; } const QString&getCC()const{ return cc; } void setCC( const QString&s ) { cc = s; } const QString&getBCC()const { return bcc; } void setBCC( const QString&s ) { bcc = s; } const QString&getMessage()const { return message; } void setMessage( const QString&s ) { message = s; } const QString&getSubject()const { return subject; } void setSubject( const QString&s ) { subject = s; } const QString&getReply()const{ return reply; } void setReply( const QString&a ) { reply = a; } private: QList<Attachment> attList; QString name, mail, to, cc, bcc, reply, subject, message; }; class Folder : public QObject { Q_OBJECT public: Folder( const QString&init_name ); const QString&getDisplayName()const { return nameDisplay; } const QString&getName()const { return name; } virtual bool may_select()const{return true;}; -private: +protected: QString nameDisplay, name; }; class IMAPFolder : public Folder { public: - IMAPFolder( QString name,bool select=true ) : Folder( name ),m_MaySelect(select) {} + IMAPFolder(const QString&name,bool select=true,const QString&prefix="" ); virtual bool may_select()const{return m_MaySelect;} private: bool m_MaySelect; }; class MailWrapper : public QObject { Q_OBJECT public: MailWrapper( Settings *s ); void sendMail( Mail mail ); private: mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); mailimf_address_list *parseAddresses(const QString&addr ); mailimf_fields *createImfFields( Mail *mail ); mailmime *buildTxtPart( QString str ); mailmime *buildFilePart( QString filename, QString mimetype ); void addFileParts( mailmime *message, QList<Attachment> files ); mailmime *createMimeMail( Mail *mail ); void smtpSend( mailmime *mail ); mailimf_field *getField( mailimf_fields *fields, int type ); clist *createRcptList( mailimf_fields *fields ); char *getFrom( mailmime *mail ); SMTPaccount *getAccount( QString from ); void writeToFile( QString file, mailmime *mail ); void readFromFile( QString file, char **data, size_t *size ); static QString mailsmtpError( int err ); static QString getTmpFile(); Settings *settings; |