author | alwin <alwin> | 2003-12-14 22:30:26 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-14 22:30:26 (UTC) |
commit | bdc60d27df0fa3a861e9117547fd2bed8a39661e (patch) (side-by-side diff) | |
tree | 8dba1e590e60443ec0aff14398da665d351b0aa4 | |
parent | 172c790df9004205eda2da25832cdc88fc6481ee (diff) | |
download | opie-bdc60d27df0fa3a861e9117547fd2bed8a39661e.zip opie-bdc60d27df0fa3a861e9117547fd2bed8a39661e.tar.gz opie-bdc60d27df0fa3a861e9117547fd2bed8a39661e.tar.bz2 |
-answered mails get another pic (checked in in pics/opiemail)
-if a description for an attachment exists it will displayed
-if mailbody is selected from list of attachments it will displayd without
menu
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 32 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/viewmailbase.cpp | 5 |
10 files changed, 64 insertions, 22 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 0ce2c6c..ad95384 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp @@ -651,123 +651,126 @@ void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_bas sub = ""; } qDebug("Type = %s/%s",type.latin1(),sub.latin1()); target_part.setType(type.lower()); target_part.setSubtype(sub.lower()); fillBodyFields(target_part,which->bd_fields); } void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) { if (!which) return; if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { clistcell*cur; mailimap_single_body_fld_param*param=0; for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { param = (mailimap_single_body_fld_param*)cur->data; if (param) { target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); } } } mailimap_body_fld_enc*enc = which->bd_encoding; QString encoding(""); switch (enc->enc_type) { case MAILIMAP_BODY_FLD_ENC_7BIT: encoding = "7bit"; break; case MAILIMAP_BODY_FLD_ENC_8BIT: encoding = "8bit"; break; case MAILIMAP_BODY_FLD_ENC_BINARY: encoding="binary"; break; case MAILIMAP_BODY_FLD_ENC_BASE64: encoding="base64"; break; case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: encoding="quoted-printable"; break; case MAILIMAP_BODY_FLD_ENC_OTHER: default: if (enc->enc_value) { char*t=enc->enc_value; encoding=QString(enc->enc_value); enc->enc_value=0L; free(t); } } + if (which->bd_description) { + target_part.setDescription(QString(which->bd_description)); + } target_part.setEncoding(encoding); target_part.setSize(which->bd_size); } QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) { return fetchPart(mail,part.Positionlist(),false); } void IMAPwrapper::deleteMail(const RecMail&mail) { mailimap_flag_list*flist; mailimap_set *set; mailimap_store_att_flags * store_flags; int err; login(); if (!m_imap) { return; } const char *mb = mail.getMbox().latin1(); err = mailimap_select( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); return; } flist = mailimap_flag_list_new_empty(); mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); store_flags = mailimap_store_att_flags_new_set_flags(flist); set = mailimap_set_new_single(mail.getNumber()); err = mailimap_store(m_imap,set,store_flags); mailimap_set_free( set ); mailimap_store_att_flags_free(store_flags); if (err != MAILIMAP_NO_ERROR) { qDebug("error deleting mail: %s",m_imap->imap_response); return; } qDebug("deleting mail: %s",m_imap->imap_response); /* should we realy do that at this moment? */ err = mailimap_expunge(m_imap); if (err != MAILIMAP_NO_ERROR) { qDebug("error deleting mail: %s",m_imap->imap_response); } qDebug("Delete successfull %s",m_imap->imap_response); } void IMAPwrapper::answeredMail(const RecMail&mail) { mailimap_flag_list*flist; mailimap_set *set; mailimap_store_att_flags * store_flags; int err; login(); if (!m_imap) { return; } const char *mb = mail.getMbox().latin1(); err = mailimap_select( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox for mark: %s",m_imap->imap_response); return; } flist = mailimap_flag_list_new_empty(); mailimap_flag_list_add(flist,mailimap_flag_new_answered()); - store_flags = mailimap_store_att_flags_new_set_flags(flist); + store_flags = mailimap_store_att_flags_new_add_flags(flist); set = mailimap_set_new_single(mail.getNumber()); err = mailimap_store(m_imap,set,store_flags); mailimap_set_free( set ); mailimap_store_att_flags_free(store_flags); if (err != MAILIMAP_NO_ERROR) { qDebug("error marking mail: %s",m_imap->imap_response); return; } } diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 0ce2c6c..ad95384 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -651,123 +651,126 @@ void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_bas sub = ""; } qDebug("Type = %s/%s",type.latin1(),sub.latin1()); target_part.setType(type.lower()); target_part.setSubtype(sub.lower()); fillBodyFields(target_part,which->bd_fields); } void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) { if (!which) return; if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { clistcell*cur; mailimap_single_body_fld_param*param=0; for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { param = (mailimap_single_body_fld_param*)cur->data; if (param) { target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); } } } mailimap_body_fld_enc*enc = which->bd_encoding; QString encoding(""); switch (enc->enc_type) { case MAILIMAP_BODY_FLD_ENC_7BIT: encoding = "7bit"; break; case MAILIMAP_BODY_FLD_ENC_8BIT: encoding = "8bit"; break; case MAILIMAP_BODY_FLD_ENC_BINARY: encoding="binary"; break; case MAILIMAP_BODY_FLD_ENC_BASE64: encoding="base64"; break; case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: encoding="quoted-printable"; break; case MAILIMAP_BODY_FLD_ENC_OTHER: default: if (enc->enc_value) { char*t=enc->enc_value; encoding=QString(enc->enc_value); enc->enc_value=0L; free(t); } } + if (which->bd_description) { + target_part.setDescription(QString(which->bd_description)); + } target_part.setEncoding(encoding); target_part.setSize(which->bd_size); } QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) { return fetchPart(mail,part.Positionlist(),false); } void IMAPwrapper::deleteMail(const RecMail&mail) { mailimap_flag_list*flist; mailimap_set *set; mailimap_store_att_flags * store_flags; int err; login(); if (!m_imap) { return; } const char *mb = mail.getMbox().latin1(); err = mailimap_select( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); return; } flist = mailimap_flag_list_new_empty(); mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); store_flags = mailimap_store_att_flags_new_set_flags(flist); set = mailimap_set_new_single(mail.getNumber()); err = mailimap_store(m_imap,set,store_flags); mailimap_set_free( set ); mailimap_store_att_flags_free(store_flags); if (err != MAILIMAP_NO_ERROR) { qDebug("error deleting mail: %s",m_imap->imap_response); return; } qDebug("deleting mail: %s",m_imap->imap_response); /* should we realy do that at this moment? */ err = mailimap_expunge(m_imap); if (err != MAILIMAP_NO_ERROR) { qDebug("error deleting mail: %s",m_imap->imap_response); } qDebug("Delete successfull %s",m_imap->imap_response); } void IMAPwrapper::answeredMail(const RecMail&mail) { mailimap_flag_list*flist; mailimap_set *set; mailimap_store_att_flags * store_flags; int err; login(); if (!m_imap) { return; } const char *mb = mail.getMbox().latin1(); err = mailimap_select( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox for mark: %s",m_imap->imap_response); return; } flist = mailimap_flag_list_new_empty(); mailimap_flag_list_add(flist,mailimap_flag_new_answered()); - store_flags = mailimap_store_att_flags_new_set_flags(flist); + store_flags = mailimap_store_att_flags_new_add_flags(flist); set = mailimap_set_new_single(mail.getNumber()); err = mailimap_store(m_imap,set,store_flags); mailimap_set_free( set ); mailimap_store_att_flags_free(store_flags); if (err != MAILIMAP_NO_ERROR) { qDebug("error marking mail: %s",m_imap->imap_response); return; } } diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 94f5d6f..8d9b247 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp @@ -40,166 +40,176 @@ void RecMail::init() { to.clear(); cc.clear(); bcc.clear(); wrapper = 0; } void RecMail::setWrapper(AbstractMail*awrapper) { wrapper = awrapper; } AbstractMail* RecMail::Wrapper() { return wrapper; } void RecMail::setTo(const QStringList&list) { to = list; } const QStringList&RecMail::To()const { return to; } void RecMail::setCC(const QStringList&list) { cc = list; } const QStringList&RecMail::CC()const { return cc; } void RecMail::setBcc(const QStringList&list) { bcc = list; } const QStringList& RecMail::Bcc()const { return bcc; } RecPart::RecPart() - : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0),m_size(0) + : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) { m_Parameters.clear(); m_poslist.clear(); } RecPart::~RecPart() { } void RecPart::setSize(unsigned int size) { m_size = size; } const unsigned int RecPart::Size()const { return m_size; } void RecPart::setLines(unsigned int lines) { m_lines = lines; } const unsigned int RecPart::Lines()const { return m_lines; } const QString& RecPart::Type()const { return m_type; } void RecPart::setType(const QString&type) { m_type = type; } const QString& RecPart::Subtype()const { return m_subtype; } void RecPart::setSubtype(const QString&subtype) { m_subtype = subtype; } const QString& RecPart::Identifier()const { return m_identifier; } void RecPart::setIdentifier(const QString&identifier) { m_identifier = identifier; } const QString& RecPart::Encoding()const { return m_encoding; } void RecPart::setEncoding(const QString&encoding) { m_encoding = encoding; } +const QString& RecPart::Description()const +{ + return m_description; +} + +void RecPart::setDescription(const QString&desc) +{ + m_description = desc; +} + void RecPart::setParameters(const part_plist_t&list) { m_Parameters = list; } const part_plist_t& RecPart::Parameters()const { return m_Parameters; } void RecPart::addParameter(const QString&key,const QString&value) { m_Parameters[key]=value; } const QString RecPart::searchParamter(const QString&key)const { QString value(""); part_plist_t::ConstIterator it = m_Parameters.find(key); if (it != m_Parameters.end()) { value = it.data(); } return value; } void RecPart::setPositionlist(const QValueList<int>&poslist) { m_poslist = poslist; } const QValueList<int>& RecPart::Positionlist()const { return m_poslist; } RecBody::RecBody() : m_BodyText(),m_PartsList(),m_description() { m_PartsList.clear(); } RecBody::~RecBody() { } void RecBody::setBodytext(const QString&bodyText) { m_BodyText = bodyText; diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 9ef762d..7d7bebc 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h @@ -35,102 +35,104 @@ public: RecMail(const RecMail&old); virtual ~RecMail(); const int getNumber()const{return msg_number;} void setNumber(int number){msg_number=number;} const QString&getDate()const{ return date; } void setDate( const QString&a ) { date = a; } const QString&getFrom()const{ return from; } void setFrom( const QString&a ) { from = a; } const QString&getSubject()const { return subject; } void setSubject( const QString&s ) { subject = s; } const QString&getMbox()const{return mbox;} void setMbox(const QString&box){mbox = box;} void setMsgid(const QString&id){msg_id=id;} const QString&Msgid()const{return msg_id;} void setReplyto(const QString&reply){replyto=reply;} const QString&Replyto()const{return replyto;} void setMsgsize(int size){msg_size = size;} const int Msgsize()const{return msg_size;} void setTo(const QStringList&list); const QStringList&To()const; void setCC(const QStringList&list); const QStringList&CC()const; void setBcc(const QStringList&list); const QStringList&Bcc()const; const QBitArray&getFlags()const{return msg_flags;} void setFlags(const QBitArray&flags){msg_flags = flags;} void setWrapper(AbstractMail*wrapper); AbstractMail* Wrapper(); protected: QString subject,date,from,mbox,msg_id,replyto; int msg_number,msg_size; QBitArray msg_flags; QStringList to,cc,bcc; AbstractMail*wrapper; void init(); void copy_old(const RecMail&old); }; typedef QMap<QString,QString> part_plist_t; class RecPart { protected: - QString m_type,m_subtype,m_identifier,m_encoding; + QString m_type,m_subtype,m_identifier,m_encoding,m_description; unsigned int m_lines,m_size; part_plist_t m_Parameters; /* describes the position in the mail */ QValueList<int> m_poslist; public: RecPart(); virtual ~RecPart(); const QString&Type()const; void setType(const QString&type); const QString&Subtype()const; void setSubtype(const QString&subtype); const QString&Identifier()const; void setIdentifier(const QString&identifier); const QString&Encoding()const; void setEncoding(const QString&encoding); + const QString&Description()const; + void setDescription(const QString&desc); void setLines(unsigned int lines); const unsigned int Lines()const; void setSize(unsigned int size); const unsigned int Size()const; void setParameters(const part_plist_t&list); const part_plist_t&Parameters()const; void addParameter(const QString&key,const QString&value); const QString searchParamter(const QString&key)const; void setPositionlist(const QValueList<int>&poslist); const QValueList<int>& Positionlist()const; }; class RecBody { protected: QString m_BodyText; QValueList<RecPart> m_PartsList; RecPart m_description; public: RecBody(); virtual ~RecBody(); void setBodytext(const QString&); const QString& Bodytext()const; void setDescription(const RecPart&des); const RecPart& Description()const; void setParts(const QValueList<RecPart>&parts); const QValueList<RecPart>& Parts()const; void addPart(const RecPart&part); }; #endif diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp index 94f5d6f..8d9b247 100644 --- a/noncore/net/mail/mailtypes.cpp +++ b/noncore/net/mail/mailtypes.cpp @@ -40,166 +40,176 @@ void RecMail::init() { to.clear(); cc.clear(); bcc.clear(); wrapper = 0; } void RecMail::setWrapper(AbstractMail*awrapper) { wrapper = awrapper; } AbstractMail* RecMail::Wrapper() { return wrapper; } void RecMail::setTo(const QStringList&list) { to = list; } const QStringList&RecMail::To()const { return to; } void RecMail::setCC(const QStringList&list) { cc = list; } const QStringList&RecMail::CC()const { return cc; } void RecMail::setBcc(const QStringList&list) { bcc = list; } const QStringList& RecMail::Bcc()const { return bcc; } RecPart::RecPart() - : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0),m_size(0) + : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) { m_Parameters.clear(); m_poslist.clear(); } RecPart::~RecPart() { } void RecPart::setSize(unsigned int size) { m_size = size; } const unsigned int RecPart::Size()const { return m_size; } void RecPart::setLines(unsigned int lines) { m_lines = lines; } const unsigned int RecPart::Lines()const { return m_lines; } const QString& RecPart::Type()const { return m_type; } void RecPart::setType(const QString&type) { m_type = type; } const QString& RecPart::Subtype()const { return m_subtype; } void RecPart::setSubtype(const QString&subtype) { m_subtype = subtype; } const QString& RecPart::Identifier()const { return m_identifier; } void RecPart::setIdentifier(const QString&identifier) { m_identifier = identifier; } const QString& RecPart::Encoding()const { return m_encoding; } void RecPart::setEncoding(const QString&encoding) { m_encoding = encoding; } +const QString& RecPart::Description()const +{ + return m_description; +} + +void RecPart::setDescription(const QString&desc) +{ + m_description = desc; +} + void RecPart::setParameters(const part_plist_t&list) { m_Parameters = list; } const part_plist_t& RecPart::Parameters()const { return m_Parameters; } void RecPart::addParameter(const QString&key,const QString&value) { m_Parameters[key]=value; } const QString RecPart::searchParamter(const QString&key)const { QString value(""); part_plist_t::ConstIterator it = m_Parameters.find(key); if (it != m_Parameters.end()) { value = it.data(); } return value; } void RecPart::setPositionlist(const QValueList<int>&poslist) { m_poslist = poslist; } const QValueList<int>& RecPart::Positionlist()const { return m_poslist; } RecBody::RecBody() : m_BodyText(),m_PartsList(),m_description() { m_PartsList.clear(); } RecBody::~RecBody() { } void RecBody::setBodytext(const QString&bodyText) { m_BodyText = bodyText; diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h index 9ef762d..7d7bebc 100644 --- a/noncore/net/mail/mailtypes.h +++ b/noncore/net/mail/mailtypes.h @@ -35,102 +35,104 @@ public: RecMail(const RecMail&old); virtual ~RecMail(); const int getNumber()const{return msg_number;} void setNumber(int number){msg_number=number;} const QString&getDate()const{ return date; } void setDate( const QString&a ) { date = a; } const QString&getFrom()const{ return from; } void setFrom( const QString&a ) { from = a; } const QString&getSubject()const { return subject; } void setSubject( const QString&s ) { subject = s; } const QString&getMbox()const{return mbox;} void setMbox(const QString&box){mbox = box;} void setMsgid(const QString&id){msg_id=id;} const QString&Msgid()const{return msg_id;} void setReplyto(const QString&reply){replyto=reply;} const QString&Replyto()const{return replyto;} void setMsgsize(int size){msg_size = size;} const int Msgsize()const{return msg_size;} void setTo(const QStringList&list); const QStringList&To()const; void setCC(const QStringList&list); const QStringList&CC()const; void setBcc(const QStringList&list); const QStringList&Bcc()const; const QBitArray&getFlags()const{return msg_flags;} void setFlags(const QBitArray&flags){msg_flags = flags;} void setWrapper(AbstractMail*wrapper); AbstractMail* Wrapper(); protected: QString subject,date,from,mbox,msg_id,replyto; int msg_number,msg_size; QBitArray msg_flags; QStringList to,cc,bcc; AbstractMail*wrapper; void init(); void copy_old(const RecMail&old); }; typedef QMap<QString,QString> part_plist_t; class RecPart { protected: - QString m_type,m_subtype,m_identifier,m_encoding; + QString m_type,m_subtype,m_identifier,m_encoding,m_description; unsigned int m_lines,m_size; part_plist_t m_Parameters; /* describes the position in the mail */ QValueList<int> m_poslist; public: RecPart(); virtual ~RecPart(); const QString&Type()const; void setType(const QString&type); const QString&Subtype()const; void setSubtype(const QString&subtype); const QString&Identifier()const; void setIdentifier(const QString&identifier); const QString&Encoding()const; void setEncoding(const QString&encoding); + const QString&Description()const; + void setDescription(const QString&desc); void setLines(unsigned int lines); const unsigned int Lines()const; void setSize(unsigned int size); const unsigned int Size()const; void setParameters(const part_plist_t&list); const part_plist_t&Parameters()const; void addParameter(const QString&key,const QString&value); const QString searchParamter(const QString&key)const; void setPositionlist(const QValueList<int>&poslist); const QValueList<int>& Positionlist()const; }; class RecBody { protected: QString m_BodyText; QValueList<RecPart> m_PartsList; RecPart m_description; public: RecBody(); virtual ~RecBody(); void setBodytext(const QString&); const QString& Bodytext()const; void setDescription(const RecPart&des); const RecPart& Description()const; void setParts(const QValueList<RecPart>&parts); const QValueList<RecPart>& Parts()const; void addPart(const RecPart&part); }; #endif diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index fae3e97..8e2132e 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -154,69 +154,71 @@ void MainWindow::refreshMailView(QList<RecMail>*list) { MailListViewItem*item = 0; mailView->clear(); for (unsigned int i = 0; i < list->count();++i) { item = new MailListViewItem(mailView,item); item->storeData(*(list->at(i))); item->showEntry(); } } void MainWindow::displayMail(QListViewItem*item) { if (!item) return; RecMail mail = ((MailListViewItem*)item)->data(); RecBody body = folderView->fetchBody(mail); ViewMail readMail( this ); readMail.setBody( body ); readMail.setMail( mail ); readMail.showMaximized(); readMail.exec(); if ( readMail.deleted ) { folderView->refreshCurrent(); } else { ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); } } void MainWindow::slotDeleteMail() { if (!mailView->currentItem()) return; RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { mail.Wrapper()->deleteMail( mail ); folderView->refreshCurrent(); } } MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) :QListViewItem(parent,item),mail_data() { } void MailListViewItem::showEntry() { - if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { + if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { + setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgreplied") ); + } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); } else { setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); } setText(1,mail_data.getSubject()); setText(2,mail_data.getFrom()); setText(3,mail_data.getDate()); } void MailListViewItem::storeData(const RecMail&data) { mail_data = data; } const RecMail& MailListViewItem::data()const { return mail_data; } diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 68d3c51..48b71eb 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp @@ -1,174 +1,182 @@ #include <qtextbrowser.h> #include <qmessagebox.h> #include <qtextstream.h> #include <qaction.h> #include <qpopupmenu.h> #include <qapplication.h> #include <opie/ofiledialog.h> #include "settings.h" #include "composemail.h" #include "viewmail.h" #include "abstractmail.h" #include "accountview.h" -AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) +AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, + const QString&fsize,int num) : QListViewItem(parent,after),_partNum(num) { setText(0, mime); - setText(1, file); - setText(2, desc); + setText(1, desc); + setText(2, file); + setText(3, fsize); } void ViewMail::setBody( RecBody body ) { m_body = body; m_mail[2] = body.Bodytext(); attachbutton->setEnabled(body.Parts().count()>0); attachments->setEnabled(body.Parts().count()>0); if (body.Parts().count()==0) { return; } AttachItem * curItem=0; QString type=body.Description().Type()+"/"+body.Description().Subtype(); -QString desc; +QString desc,fsize; double s = body.Description().Size(); int w; w=0; while (s>1024) { s/=1024; ++w; if (w>=2) break; } QString q=""; switch(w) { case 1: q="k"; break; case 2: q="M"; break; default: break; } { /* I did not found a method to make a CONTENT reset on a QTextStream so I use this construct that the stream will re-constructed in each loop. To let it work, the textstream is packed into a own area of code is it will be destructed after finishing its small job. */ - QTextOStream o(&desc); + QTextOStream o(&fsize); if (w>0) o.precision(2); else o.precision(0); o.setf(QTextStream::fixed); o << s << " " << q << "Byte"; } -curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); +curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1); QString filename = ""; for (unsigned int i = 0; i < body.Parts().count();++i) { type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); for (;it!=body.Parts()[i].Parameters().end();++it) { + qDebug(it.key()); if (it.key().lower()=="name") { filename=it.data(); } } s = body.Parts()[i].Size(); w = 0; while (s>1024) { s/=1024; ++w; if (w>=2) break; } switch(w) { case 1: q="k"; break; case 2: q="M"; break; default: q=""; break; } - QTextOStream o(&desc); + QTextOStream o(&fsize); if (w>0) o.precision(2); else o.precision(0); o.setf(QTextStream::fixed); o << s << " " << q << "Byte"; - curItem=new AttachItem(attachments,curItem,type,filename,desc,i); + desc = body.Parts()[i].Description(); + curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i); } } -void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { +void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { if (!item ) return; - QPopupMenu *menu = new QPopupMenu(); + if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { + setText(); + return; + } + QPopupMenu *menu = new QPopupMenu(); int ret=0; - if ( item->text( 0 ).left( 4 ) == "text" ) { + if ( item->text( 0 ).left( 5 ) == "text/" ) { menu->insertItem( tr( "Show Text" ), 1 ); } menu->insertItem( tr( "Save Attachment" ), 0 ); menu->insertSeparator(1); ret = menu->exec( point, 0 ); switch(ret) { case 0: { MimeTypes types; types.insert( "all", "*" ); QString str = OFileDialog::getSaveFileName( 1, - "/", item->text( 1 ) , types, 0 ); + "/", item->text( 2 ) , types, 0 ); if( !str.isEmpty() ) { qDebug( "first we will need a MIME wrapper" ); } } break ; case 1: if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { setText(); } else { if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); } } break; } delete menu; } void ViewMail::setMail( RecMail mail ) { m_recMail = mail; m_mail[0] = mail.getFrom(); m_mail[1] = mail.getSubject(); m_mail[3] = mail.getDate(); m_mail[4] = mail.Msgid(); m_mail2[0] = mail.To(); m_mail2[1] = mail.CC(); m_mail2[2] = mail.Bcc(); setText(); } ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) : ViewMailBase(parent, name, fl), _inLoop(false) { m_gotBody = false; connect(reply, SIGNAL(activated()), SLOT(slotReply())); connect(forward, SIGNAL(activated()), SLOT(slotForward())); connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index 765464c..dd7f854 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h @@ -1,60 +1,61 @@ #ifndef VIEWMAIL_H #define VIEWMAIL_H #include <qlistview.h> #include <qmap.h> #include <qstringlist.h> #include "viewmailbase.h" #include "mailtypes.h" class AttachItem : public QListViewItem { public: - AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num); + AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, + const QString&fsize,int num); int Partnumber() { return _partNum; } private: int _partNum; }; class ViewMail : public ViewMailBase { Q_OBJECT public: ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); ~ViewMail(); void hide(); void exec(); void setMail( RecMail mail ); void setBody( RecBody body ); bool deleted; protected: QString deHtml(const QString &string); protected slots: void slotReply(); void slotForward(); void setText(); void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); void slotDeleteMail( ); private: bool _inLoop; QString m_mailHtml; bool m_gotBody; RecBody m_body; RecMail m_recMail; // 0 from 1 subject 2 bodytext 3 date QMap <int,QString> m_mail; // 0 to 1 cc 2 bcc QMap <int,QStringList> m_mail2; }; #endif diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp index 38f92b4..0c7f671 100644 --- a/noncore/net/mail/viewmailbase.cpp +++ b/noncore/net/mail/viewmailbase.cpp @@ -10,67 +10,68 @@ #include <qpe/resource.h> #include "viewmailbase.h" //#include "opendiag.h" ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { setCaption(tr("E-Mail by %1")); setToolBarsMovable(false); toolbar = new QToolBar(this); menubar = new QMenuBar( toolbar ); mailmenu = new QPopupMenu( menubar ); menubar->insertItem( tr( "Mail" ), mailmenu ); toolbar->setHorizontalStretchable(true); addToolBar(toolbar); QLabel *spacer = new QLabel(toolbar); spacer->setBackgroundMode(QWidget::PaletteButton); toolbar->setStretchableWidget(spacer); reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); reply->addTo(toolbar); reply->addTo(mailmenu); forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); forward->addTo(toolbar); forward->addTo(mailmenu); attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); attachbutton->addTo(toolbar); attachbutton->addTo(mailmenu); connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); deleteMail->addTo(toolbar); deleteMail->addTo(mailmenu); QVBox *view = new QVBox(this); setCentralWidget(view); attachments = new QListView(view); attachments->setMinimumHeight(90); attachments->setMaximumHeight(90); attachments->setAllColumnsShowFocus(true); attachments->addColumn("Mime Type", 60); - attachments->addColumn(tr("Filename"), 100); - attachments->addColumn(tr("Size"), 80); + attachments->addColumn(tr("Description"), 100); + attachments->addColumn(tr("Filename"), 80); + attachments->addColumn(tr("Size"), 80); attachments->setSorting(-1); attachments->hide(); browser = new QTextBrowser(view); // openDiag = new OpenDiag(view); // openDiag->hide(); } void ViewMailBase::slotChangeAttachview(bool state) { if (state) attachments->show(); else attachments->hide(); } |