summaryrefslogtreecommitdiffabout
path: root/kmicromail
authorzautrix <zautrix>2005-01-24 18:05:48 (UTC)
committer zautrix <zautrix>2005-01-24 18:05:48 (UTC)
commit77f93c632b66b5c8d92e4c63330362272ca1fc40 (patch) (unidiff)
tree31f28656062c899b5368f13ab594ff6fa5c657fa /kmicromail
parent6c89efd80c1e94a0c070025d07c7a4c656f2a81e (diff)
downloadkdepimpi-77f93c632b66b5c8d92e4c63330362272ca1fc40.zip
kdepimpi-77f93c632b66b5c8d92e4c63330362272ca1fc40.tar.gz
kdepimpi-77f93c632b66b5c8d92e4c63330362272ca1fc40.tar.bz2
mail fixes
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountview.h2
-rw-r--r--kmicromail/libmailwrapper/mailtypes.cpp17
-rw-r--r--kmicromail/libmailwrapper/mailtypes.h1
-rw-r--r--kmicromail/mailistviewitem.cpp24
-rw-r--r--kmicromail/opiemail.cpp38
-rw-r--r--kmicromail/viewmail.cpp7
6 files changed, 69 insertions, 20 deletions
diff --git a/kmicromail/accountview.h b/kmicromail/accountview.h
index fcf33d1..79ed2e7 100644
--- a/kmicromail/accountview.h
+++ b/kmicromail/accountview.h
@@ -1,46 +1,46 @@
1#ifndef ACCOUNTVIEW_H 1#ifndef ACCOUNTVIEW_H
2#define ACCOUNTVIEW_H 2#define ACCOUNTVIEW_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <opie2/osmartpointer.h> 6#include <opie2/osmartpointer.h>
7#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
8 8
9class Selectstore; 9class Selectstore;
10class Folder; 10class Folder;
11class AbstractMail; 11class AbstractMail;
12class Account; 12class Account;
13class IMAPviewItem; 13class IMAPviewItem;
14class MHviewItem; 14class MHviewItem;
15 15
16class AccountView : public QListView 16class AccountView : public QListView
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19 19
20public: 20public:
21 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 21 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
22 virtual ~AccountView(); 22 virtual ~AccountView();
23 virtual void populate( QList<Account> list ); 23 virtual void populate( QList<Account> list );
24 virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail); 24 virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail);
25 virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); 25 virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper);
26 virtual void downloadMailsInbox(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); 26 virtual void downloadMailsInbox(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper);
27 virtual bool currentisDraft(); 27 virtual bool currentisDraft();
28 28 QValueList<MHviewItem*> allAccounts() { return mhAccounts;}
29public slots: 29public slots:
30 virtual void refreshAll(); 30 virtual void refreshAll();
31 virtual void refresh(QListViewItem *item); 31 virtual void refresh(QListViewItem *item);
32 virtual void refreshCurrent(); 32 virtual void refreshCurrent();
33 virtual void slotHold(int, QListViewItem *,const QPoint&,int); 33 virtual void slotHold(int, QListViewItem *,const QPoint&,int);
34 virtual void slotContextMenu(int id); 34 virtual void slotContextMenu(int id);
35 void setupFolderselect(Selectstore*sels); 35 void setupFolderselect(Selectstore*sels);
36 36
37signals: 37signals:
38 void refreshMailview(const QValueList<RecMailP>& ); 38 void refreshMailview(const QValueList<RecMailP>& );
39 39
40protected: 40protected:
41 QListViewItem* m_currentItem; 41 QListViewItem* m_currentItem;
42 QValueList<IMAPviewItem*> imapAccounts; 42 QValueList<IMAPviewItem*> imapAccounts;
43 QValueList<MHviewItem*> mhAccounts; 43 QValueList<MHviewItem*> mhAccounts;
44}; 44};
45 45
46#endif 46#endif
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp
index 89150ad..96d55e6 100644
--- a/kmicromail/libmailwrapper/mailtypes.cpp
+++ b/kmicromail/libmailwrapper/mailtypes.cpp
@@ -1,80 +1,97 @@
1#include "mailtypes.h" 1#include "mailtypes.h"
2 2
3//#include <opie2/odebug.h> 3//#include <opie2/odebug.h>
4 4
5#include <stdlib.h> 5#include <stdlib.h>
6 6
7using namespace Opie::Core; 7using namespace Opie::Core;
8RecMail::RecMail() 8RecMail::RecMail()
9 :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) 9 :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
10{ 10{
11 init(); 11 init();
12} 12}
13 13
14RecMail::RecMail(const RecMail&old) 14RecMail::RecMail(const RecMail&old)
15 :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) 15 :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
16{ 16{
17 init(); 17 init();
18 copy_old(old); 18 copy_old(old);
19 // odebug << "Copy constructor RecMail" << oendl; 19 // odebug << "Copy constructor RecMail" << oendl;
20} 20}
21 21
22RecMail::~RecMail() 22RecMail::~RecMail()
23{ 23{
24 wrapper = 0; 24 wrapper = 0;
25} 25}
26static bool stringCompareRec( const QString& s1, const QString& s2 ) 26static bool stringCompareRec( const QString& s1, const QString& s2 )
27{ 27{
28 if ( s1.isEmpty() && s2.isEmpty() ) 28 if ( s1.isEmpty() && s2.isEmpty() )
29 return true; 29 return true;
30 return s1 == s2; 30 return s1 == s2;
31} 31}
32 32
33const QString RecMail::MsgsizeString() const
34{
35
36 double s = msg_size;
37 int w = 0;
38 s/=1024;
39 if (s>999.0) {
40 s/=1024.0;
41 ++w;
42 }
43 QString fsize = QString::number( s, 'f', 2 );
44 if ( w == 0 ) {
45 fsize += "kB" ;
46 } else
47 fsize += "MB" ;
48 return fsize;
49}
33bool RecMail::isEqual( RecMail* r1 ) 50bool RecMail::isEqual( RecMail* r1 )
34{ 51{
35 if ( !stringCompareRec( isodate, r1->isodate ) ) { 52 if ( !stringCompareRec( isodate, r1->isodate ) ) {
36 //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); 53 //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1());
37 return false; 54 return false;
38 } 55 }
39 if ( !stringCompareRec( subject.left(40), r1->subject.left(40) ) ) { 56 if ( !stringCompareRec( subject.left(40), r1->subject.left(40) ) ) {
40 //qDebug("sub *%s* *%s*", subject.latin1(), r1->subject.latin1()); 57 //qDebug("sub *%s* *%s*", subject.latin1(), r1->subject.latin1());
41 return false; 58 return false;
42 } 59 }
43 60
44 //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); 61 //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1());
45 if ( !stringCompareRec( from.left(40), r1->from.left(40)) ) { 62 if ( !stringCompareRec( from.left(40), r1->from.left(40)) ) {
46 if ( r1->from.find ( from ) < 0 ) { 63 if ( r1->from.find ( from ) < 0 ) {
47 if ( !stringCompareRec( from.simplifyWhiteSpace ().left(40), r1->from.simplifyWhiteSpace ().left(40)) ) { 64 if ( !stringCompareRec( from.simplifyWhiteSpace ().left(40), r1->from.simplifyWhiteSpace ().left(40)) ) {
48 //qDebug("from *%s* *%s* ", from.left(40).latin1(), r1->from.left(20).latin1()); 65 //qDebug("from *%s* *%s* ", from.left(40).latin1(), r1->from.left(20).latin1());
49 return false; 66 return false;
50 } 67 }
51 } 68 }
52 } 69 }
53 70
54 return true; 71 return true;
55} 72}
56void RecMail::copy_old(const RecMail&old) 73void RecMail::copy_old(const RecMail&old)
57{ 74{
58 subject = old.subject; 75 subject = old.subject;
59 date = old.date; 76 date = old.date;
60 mbox = old.mbox; 77 mbox = old.mbox;
61 msg_id = old.msg_id; 78 msg_id = old.msg_id;
62 msg_size = old.msg_size; 79 msg_size = old.msg_size;
63 msg_number = old.msg_number; 80 msg_number = old.msg_number;
64 from = old.from; 81 from = old.from;
65 msg_flags = old.msg_flags; 82 msg_flags = old.msg_flags;
66 to = old.to; 83 to = old.to;
67 cc = old.cc; 84 cc = old.cc;
68 bcc = old.bcc; 85 bcc = old.bcc;
69 wrapper = old.wrapper; 86 wrapper = old.wrapper;
70 in_reply_to = old.in_reply_to; 87 in_reply_to = old.in_reply_to;
71 references = old.references; 88 references = old.references;
72 replyto = old.replyto; 89 replyto = old.replyto;
73} 90}
74 91
75void RecMail::init() 92void RecMail::init()
76{ 93{
77 to.clear(); 94 to.clear();
78 cc.clear(); 95 cc.clear();
79 bcc.clear(); 96 bcc.clear();
80 in_reply_to.clear(); 97 in_reply_to.clear();
diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h
index 32d92c0..39c0bac 100644
--- a/kmicromail/libmailwrapper/mailtypes.h
+++ b/kmicromail/libmailwrapper/mailtypes.h
@@ -10,96 +10,97 @@
10 10
11#include <opie2/osmartpointer.h> 11#include <opie2/osmartpointer.h>
12 12
13#include <qbitarray.h> 13#include <qbitarray.h>
14#include <qstring.h> 14#include <qstring.h>
15#include <qstringlist.h> 15#include <qstringlist.h>
16#include <qmap.h> 16#include <qmap.h>
17#include <qvaluelist.h> 17#include <qvaluelist.h>
18 18
19class AbstractMail; 19class AbstractMail;
20/* a class to describe mails in a mailbox */ 20/* a class to describe mails in a mailbox */
21/* Attention! 21/* Attention!
22 From programmers point of view it would make sense to 22 From programmers point of view it would make sense to
23 store the mail body into this class, too. 23 store the mail body into this class, too.
24 But: not from the point of view of the device. 24 But: not from the point of view of the device.
25 Mailbodies can be real large. So we request them when 25 Mailbodies can be real large. So we request them when
26 needed from the mail-wrapper class direct from the server itself 26 needed from the mail-wrapper class direct from the server itself
27 (imap) or from a file-based cache (pop3?) 27 (imap) or from a file-based cache (pop3?)
28 So there is no interface "const QString&body()" but you should 28 So there is no interface "const QString&body()" but you should
29 make a request to the mailwrapper with this class as parameter to 29 make a request to the mailwrapper with this class as parameter to
30 get the body. Same words for the attachments. 30 get the body. Same words for the attachments.
31*/ 31*/
32class RecMail:public Opie::Core::ORefCount 32class RecMail:public Opie::Core::ORefCount
33{ 33{
34public: 34public:
35 RecMail(); 35 RecMail();
36 RecMail(const RecMail&old); 36 RecMail(const RecMail&old);
37 virtual ~RecMail(); 37 virtual ~RecMail();
38 bool isEqual( RecMail* r1 ); 38 bool isEqual( RecMail* r1 );
39 39
40 const unsigned int getNumber()const{return msg_number;} 40 const unsigned int getNumber()const{return msg_number;}
41 void setNumber(unsigned int number){msg_number=number;} 41 void setNumber(unsigned int number){msg_number=number;}
42 const QString&getDate()const{ return date; } 42 const QString&getDate()const{ return date; }
43 void setDate( const QString&a ) { date = a; } 43 void setDate( const QString&a ) { date = a; }
44 const QString&getIsoDate()const{ return isodate; } 44 const QString&getIsoDate()const{ return isodate; }
45 void setIsoDate( const QString&a ) { isodate = a; } 45 void setIsoDate( const QString&a ) { isodate = a; }
46 const QString&getFrom()const{ return from; } 46 const QString&getFrom()const{ return from; }
47 void setFrom( const QString&a ) { from = a; } 47 void setFrom( const QString&a ) { from = a; }
48 const QString&getSubject()const { return subject; } 48 const QString&getSubject()const { return subject; }
49 void setSubject( const QString&s ) { subject = s; } 49 void setSubject( const QString&s ) { subject = s; }
50 const QString&getMbox()const{return mbox;} 50 const QString&getMbox()const{return mbox;}
51 void setMbox(const QString&box){mbox = box;} 51 void setMbox(const QString&box){mbox = box;}
52 void setMsgid(const QString&id){msg_id=id;} 52 void setMsgid(const QString&id){msg_id=id;}
53 const QString&Msgid()const{return msg_id;} 53 const QString&Msgid()const{return msg_id;}
54 void setReplyto(const QString&reply){replyto=reply;} 54 void setReplyto(const QString&reply){replyto=reply;}
55 const QString&Replyto()const{return replyto;} 55 const QString&Replyto()const{return replyto;}
56 void setMsgsize(unsigned int size){msg_size = size;} 56 void setMsgsize(unsigned int size){msg_size = size;}
57 const unsigned int Msgsize()const{return msg_size;} 57 const unsigned int Msgsize()const{return msg_size;}
58 const QString MsgsizeString()const;
58 59
59 60
60 void setTo(const QStringList&list); 61 void setTo(const QStringList&list);
61 const QStringList&To()const; 62 const QStringList&To()const;
62 void setCC(const QStringList&list); 63 void setCC(const QStringList&list);
63 const QStringList&CC()const; 64 const QStringList&CC()const;
64 void setBcc(const QStringList&list); 65 void setBcc(const QStringList&list);
65 const QStringList&Bcc()const; 66 const QStringList&Bcc()const;
66 void setInreply(const QStringList&list); 67 void setInreply(const QStringList&list);
67 const QStringList&Inreply()const; 68 const QStringList&Inreply()const;
68 void setReferences(const QStringList&list); 69 void setReferences(const QStringList&list);
69 const QStringList&References()const; 70 const QStringList&References()const;
70 71
71 const QBitArray&getFlags()const{return msg_flags;} 72 const QBitArray&getFlags()const{return msg_flags;}
72 void setFlags(const QBitArray&flags){msg_flags = flags;} 73 void setFlags(const QBitArray&flags){msg_flags = flags;}
73 74
74 void setWrapper(AbstractMail*wrapper); 75 void setWrapper(AbstractMail*wrapper);
75 AbstractMail* Wrapper(); 76 AbstractMail* Wrapper();
76 // public for debugging 77 // public for debugging
77 QString subject,date,isodate,from,mbox,msg_id,replyto; 78 QString subject,date,isodate,from,mbox,msg_id,replyto;
78 79
79protected: 80protected:
80 //QString subject,date,isodate,from,mbox,msg_id,replyto; 81 //QString subject,date,isodate,from,mbox,msg_id,replyto;
81 unsigned int msg_number,msg_size; 82 unsigned int msg_number,msg_size;
82 QBitArray msg_flags; 83 QBitArray msg_flags;
83 QStringList to,cc,bcc,in_reply_to,references; 84 QStringList to,cc,bcc,in_reply_to,references;
84 AbstractMail*wrapper; 85 AbstractMail*wrapper;
85 void init(); 86 void init();
86 void copy_old(const RecMail&old); 87 void copy_old(const RecMail&old);
87}; 88};
88 89
89typedef Opie::Core::OSmartPointer<RecMail> RecMailP; 90typedef Opie::Core::OSmartPointer<RecMail> RecMailP;
90typedef QMap<QString,QString> part_plist_t; 91typedef QMap<QString,QString> part_plist_t;
91 92
92class RecPart:public Opie::Core::ORefCount 93class RecPart:public Opie::Core::ORefCount
93{ 94{
94protected: 95protected:
95 QString m_type,m_subtype,m_identifier,m_encoding,m_description; 96 QString m_type,m_subtype,m_identifier,m_encoding,m_description;
96 unsigned int m_lines,m_size; 97 unsigned int m_lines,m_size;
97 part_plist_t m_Parameters; 98 part_plist_t m_Parameters;
98 /* describes the position in the mail */ 99 /* describes the position in the mail */
99 QValueList<int> m_poslist; 100 QValueList<int> m_poslist;
100 101
101public: 102public:
102 RecPart(); 103 RecPart();
103 RecPart(const RecPart&); 104 RecPart(const RecPart&);
104 virtual ~RecPart(); 105 virtual ~RecPart();
105 106
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp
index ffb835c..137c482 100644
--- a/kmicromail/mailistviewitem.cpp
+++ b/kmicromail/mailistviewitem.cpp
@@ -1,103 +1,95 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2#include "mailistviewitem.h" 2#include "mailistviewitem.h"
3#include <libmailwrapper/abstractmail.h> 3#include <libmailwrapper/abstractmail.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <kiconloader.h> 5#include <kiconloader.h>
6#include "koprefs.h" 6#include "koprefs.h"
7//#include <qpe/resource.h> 7//#include <qpe/resource.h>
8 8
9MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 9MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
10 :QListViewItem(parent,item),mail_data() 10 :QListViewItem(parent,item),mail_data()
11{ 11{
12} 12}
13 13
14void MailListViewItem::showEntry() 14void MailListViewItem::showEntry()
15{ 15{
16 if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { 16 if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) {
17 setPixmap( 0, SmallIcon ( "kmmsgreplied") ); 17 setPixmap( 0, SmallIcon ( "kmmsgreplied") );
18 } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { 18 } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) {
19 /* I think it looks nicer if there are not such a log of icons but only on mails 19 /* I think it looks nicer if there are not such a log of icons but only on mails
20 replied or new - Alwin*/ 20 replied or new - Alwin*/
21 //setPixmap( 0,SmallIcon ("kmmsgunseen") ); 21 //setPixmap( 0,SmallIcon ("kmmsgunseen") );
22 } else { 22 } else {
23 setPixmap( 0,SmallIcon ( "kmmsgnew") ); 23 setPixmap( 0,SmallIcon ( "kmmsgnew") );
24 } 24 }
25 double s = mail_data->Msgsize(); 25 QString fsize = mail_data->MsgsizeString();
26 int w = 0;
27 s/=1024;
28 if (s>999.0) {
29 s/=1024.0;
30 ++w;
31 }
32 QString fsort;
33 fsort.sprintf( "%.2f", s );
34 QString fsize = QString::number( s, 'f', 2 );
35 // 1.23 26 // 1.23
36 // 11.23 27 // 11.23
37 // 111.23 28 // 111.23
38 // 999.23 maxlen 29 // 999.23 maxlen
30 QString fsort;
39 switch(fsize.length() ) { 31 switch(fsize.length() ) {
40 case 4: 32 case 6:
41 fsort = "00" + fsize ; 33 fsort = "00" + fsize ;
42 break; 34 break;
43 case 5: 35 case 7:
44 fsort = "0" + fsize ; 36 fsort = "0" + fsize ;
45 break; 37 break;
46 default: 38 default:
47 fsort = fsize ; 39 fsort = fsize ;
48 break; 40 break;
49 41
50 } 42 }
51 if ( w == 0 ) { 43 setText(3, fsize );
52 setText(3, fsize + "kB" ); 44 //qDebug("fsize *%s* ",fsize.latin1() );
45 //qDebug("fsort *%s* ",fsort.latin1() );
46 if ( fsize.right(2) == "kB" ) {
53 mKeyMap.insert(3, "k" + fsort); 47 mKeyMap.insert(3, "k" + fsort);
54 //setText(3, "kB" + fsort ); // test only
55 } else { 48 } else {
56 //setText(3, fsize + "MB");
57 mKeyMap.insert(3, "M" +fsort ); 49 mKeyMap.insert(3, "M" +fsort );
58 } 50 }
59 setText(1,mail_data->getSubject()); 51 setText(1,mail_data->getSubject());
60 setText(2,mail_data->getFrom()); 52 setText(2,mail_data->getFrom());
61 mKeyMap.insert(4,mail_data->getIsoDate()); 53 mKeyMap.insert(4,mail_data->getIsoDate());
62 setText(4,mail_data->getDate()); 54 setText(4,mail_data->getDate());
63 if ( KOPrefs::instance()->mShowToField ) 55 if ( KOPrefs::instance()->mShowToField )
64 setText(5,mail_data->To()[0]); 56 setText(5,mail_data->To()[0]);
65} 57}
66 58
67void MailListViewItem::storeData(const RecMailP&data) 59void MailListViewItem::storeData(const RecMailP&data)
68{ 60{
69 mail_data = data; 61 mail_data = data;
70} 62}
71void MailListViewItem::setSortKey(int column,const QString &key) 63void MailListViewItem::setSortKey(int column,const QString &key)
72{ 64{
73 mKeyMap.insert(column,key); 65 mKeyMap.insert(column,key);
74} 66}
75QString MailListViewItem::key(int column, bool) const 67QString MailListViewItem::key(int column, bool) const
76{ 68{
77 // to make is fast, we use here special cases 69 // to make is fast, we use here special cases
78 if ( column == 3 || column == 4 ) { 70 if ( column == 3 || column == 4 ) {
79 return *mKeyMap.find(column); 71 return *mKeyMap.find(column);
80 } 72 }
81 if ( column == 1 ) { 73 if ( column == 1 ) {
82 if ( text(1).left(4).lower() == "re: " ) 74 if ( text(1).left(4).lower() == "re: " )
83 return text(1).mid(4); 75 return text(1).mid(4);
84 76
85 } 77 }
86 return text(column); 78 return text(column);
87 /* 79 /*
88 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 80 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
89 if (it == mKeyMap.end()) return text(column); 81 if (it == mKeyMap.end()) return text(column);
90 else return *it; 82 else return *it;
91 */ 83 */
92} 84}
93 85
94const RecMailP& MailListViewItem::data()const 86const RecMailP& MailListViewItem::data()const
95{ 87{
96 return mail_data; 88 return mail_data;
97} 89}
98 90
99MAILLIB::ATYPE MailListViewItem::wrapperType() 91MAILLIB::ATYPE MailListViewItem::wrapperType()
100{ 92{
101 if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; 93 if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED;
102 return mail_data->Wrapper()->getType(); 94 return mail_data->Wrapper()->getType();
103} 95}
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 6e54bf4..760e3b0 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,71 +1,72 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3 3
4 4
5#define protected public 5#define protected public
6#include <qwidget.h> 6#include <qwidget.h>
7#undef protected 7#undef protected
8#include "koprefsdialog.h" 8#include "koprefsdialog.h"
9#include <kapplication.h> 9#include <kapplication.h>
10#include <libkdepim/externalapphandler.h> 10#include <libkdepim/externalapphandler.h>
11#include <libkdepim/kpimglobalprefs.h> 11#include <libkdepim/kpimglobalprefs.h>
12#ifdef MINIKDE_KDIALOG_H 12#ifdef MINIKDE_KDIALOG_H
13#undef MINIKDE_KDIALOG_H 13#undef MINIKDE_KDIALOG_H
14#endif 14#endif
15#include "settingsdialog.h" 15#include "settingsdialog.h"
16#include "opiemail.h" 16#include "opiemail.h"
17#include "editaccounts.h" 17#include "editaccounts.h"
18#include "composemail.h" 18#include "composemail.h"
19#include "mailistviewitem.h" 19#include "mailistviewitem.h"
20#include "viewmail.h" 20#include "viewmail.h"
21#include "selectstore.h" 21#include "selectstore.h"
22#include "selectsmtp.h" 22#include "selectsmtp.h"
23#include "accountitem.h" 23#include "accountitem.h"
24#include "accountview.h"
24#include "klocale.h" 25#include "klocale.h"
25 26
26#include <qmessagebox.h> 27#include <qmessagebox.h>
27#include <qtimer.h> 28#include <qtimer.h>
28#include <qcursor.h> 29#include <qcursor.h>
29#include <qtextbrowser.h> 30#include <qtextbrowser.h>
30#include <qregexp.h> 31#include <qregexp.h>
31#include <qpe/global.h> 32#include <qpe/global.h>
32 33
33#ifdef DESKTOP_VERSION 34#ifdef DESKTOP_VERSION
34#include <qapplication.h> 35#include <qapplication.h>
35#else 36#else
36#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
37#endif 38#endif
38#include <libmailwrapper/smtpwrapper.h> 39#include <libmailwrapper/smtpwrapper.h>
39#include <libmailwrapper/mailtypes.h> 40#include <libmailwrapper/mailtypes.h>
40#include <libmailwrapper/abstractmail.h> 41#include <libmailwrapper/abstractmail.h>
41#include "koprefs.h" 42#include "koprefs.h"
42 43
43//using namespace Opie::Core; 44//using namespace Opie::Core;
44 45
45OpieMail::OpieMail( QWidget *parent, const char *name ) 46OpieMail::OpieMail( QWidget *parent, const char *name )
46 : MainWindow( parent, name) //, WStyle_ContextHelp ) 47 : MainWindow( parent, name) //, WStyle_ContextHelp )
47{ 48{
48 settings = new Settings(); 49 settings = new Settings();
49 tb = 0; 50 tb = 0;
50 setIcon(SmallIcon( "kmicromail" ) ); 51 setIcon(SmallIcon( "kmicromail" ) );
51 folderView->populate( settings->getAccounts() ); 52 folderView->populate( settings->getAccounts() );
52 53
53} 54}
54 55
55OpieMail::~OpieMail() 56OpieMail::~OpieMail()
56{ 57{
57 if (settings) delete settings; 58 if (settings) delete settings;
58 if ( tb ) 59 if ( tb )
59 delete tb; 60 delete tb;
60} 61}
61 62
62void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 63void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
63{ 64{
64 65
65} 66}
66#include <stdlib.h> 67#include <stdlib.h>
67void OpieMail::message(const QCString &msg, const QByteArray &data) 68void OpieMail::message(const QCString &msg, const QByteArray &data)
68{ 69{
69 // copied from old mail2 70 // copied from old mail2
70 static int ii = 0; 71 static int ii = 0;
71 //qDebug("QCOP CALL ############################# %d ", ii); 72 //qDebug("QCOP CALL ############################# %d ", ii);
@@ -268,97 +269,132 @@ void OpieMail::replyMail()
268 QListViewItem*item = mailView->currentItem(); 269 QListViewItem*item = mailView->currentItem();
269 if (!item) return; 270 if (!item) return;
270 RecMailP mail = ((MailListViewItem*)item)->data(); 271 RecMailP mail = ((MailListViewItem*)item)->data();
271 RecBodyP body = folderView->fetchBody(mail); 272 RecBodyP body = folderView->fetchBody(mail);
272 273
273 QString rtext; 274 QString rtext;
274 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 275 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
275 .arg( mail->getFrom()) 276 .arg( mail->getFrom())
276 .arg( mail->getDate()); 277 .arg( mail->getDate());
277 278
278 QString text = body->Bodytext(); 279 QString text = body->Bodytext();
279 QStringList lines = QStringList::split(QRegExp("\\n"), text); 280 QStringList lines = QStringList::split(QRegExp("\\n"), text);
280 QStringList::Iterator it; 281 QStringList::Iterator it;
281 for (it = lines.begin(); it != lines.end(); it++) 282 for (it = lines.begin(); it != lines.end(); it++)
282 { 283 {
283 rtext += "> " + *it + "\n"; 284 rtext += "> " + *it + "\n";
284 } 285 }
285 rtext += "\n"; 286 rtext += "\n";
286 287
287 QString prefix; 288 QString prefix;
288 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 289 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
289 else prefix = "Re: "; // no i18n on purpose 290 else prefix = "Re: "; // no i18n on purpose
290 291
291 Settings *settings = new Settings(); 292 Settings *settings = new Settings();
292 ComposeMail composer( settings ,this, 0, true); 293 ComposeMail composer( settings ,this, 0, true);
293 if (mail->Replyto().isEmpty()) { 294 if (mail->Replyto().isEmpty()) {
294 composer.setTo( mail->getFrom()); 295 composer.setTo( mail->getFrom());
295 } else { 296 } else {
296 composer.setTo( mail->Replyto()); 297 composer.setTo( mail->Replyto());
297 } 298 }
298 composer.setSubject( prefix + mail->getSubject()); 299 composer.setSubject( prefix + mail->getSubject());
299 composer.setMessage( rtext ); 300 composer.setMessage( rtext );
300 composer.setInReplyTo( mail->Msgid()); 301 composer.setInReplyTo( mail->Msgid());
301 composer.setCharset( body->getCharset() ); 302 composer.setCharset( body->getCharset() );
302 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 303 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
303 { 304 {
304 mail->Wrapper()->answeredMail(mail); 305 mail->Wrapper()->answeredMail(mail);
305 } 306 }
306 delete settings; 307 delete settings;
307 308
308} 309}
309void OpieMail::closeViewMail(ViewMail * vm) 310void OpieMail::closeViewMail(ViewMail * vm)
310{ 311{
311 vm->hide(); 312 vm->hide();
312} 313}
313 314
314void OpieMail::slotDownloadMail( ) 315void OpieMail::slotDownloadMail( )
315{ 316{
316 qDebug("slotDownloadMail( ) "); 317 QListViewItem*item = mailView->currentItem();
318 if (!item ) {
319 Global::statusMessage("Error: No item slected!");
320 return;
321 }
322 RecMailP mail = ((MailListViewItem*)item)->data();
323 Account * acc = mail->Wrapper()->getAccount();
324 if ( !acc ) {
325 Global::statusMessage("Mail is already stored locally!");
326 return;
327 }
328 QString lfName = acc->getLocalFolder();
329 //qDebug("local folder " + lfName );
330 if ( lfName.isEmpty() )
331 lfName = acc->getAccountName();
332 AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper();
333 //qDebug("target %d %d ",targetMail,mail->Wrapper() );
334 if ( targetMail == mail->Wrapper() ) {
335 Global::statusMessage("Mail is already locally stored!");
336 return;
337 }
338 if ( !targetMail->createMbox(lfName)) {
339 Global::statusMessage("Error creating folder!");
340 return;
341 }
342 Global::statusMessage("Fetching mail...please wait!");
343 qApp->processEvents();
344 encodedString*st = 0;
345 st = mail->Wrapper()->fetchRawBody(mail);
346 if ( st ) {
347 targetMail->storeMessage(st->Content(),st->Length(),lfName);
348 Global::statusMessage("Mail stored in "+ lfName);
349 delete st;
350 } else {
351 Global::statusMessage("Error: Cannot fetch mail!");
352 }
317} 353}
318 354
319 355
320void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) 356void OpieMail::deleteAndDisplayNextMail(ViewMail * vm)
321{ 357{
322 QListViewItem*item = mailView->currentItem(); 358 QListViewItem*item = mailView->currentItem();
323 if (!item ) { 359 if (!item ) {
324 closeViewMail(vm); 360 closeViewMail(vm);
325 return; 361 return;
326 } 362 }
327 RecMailP mail = ((MailListViewItem*)item)->data(); 363 RecMailP mail = ((MailListViewItem*)item)->data();
328 mail->Wrapper()->deleteMail( mail ); 364 mail->Wrapper()->deleteMail( mail );
329 item = item->itemBelow(); 365 item = item->itemBelow();
330 if (!item ) { 366 if (!item ) {
331 closeViewMail(vm); 367 closeViewMail(vm);
332 return; 368 return;
333 } 369 }
334 mailView->setCurrentItem(item); 370 mailView->setCurrentItem(item);
335 mail = ((MailListViewItem*)item)->data(); 371 mail = ((MailListViewItem*)item)->data();
336 RecBodyP body = folderView->fetchBody(mail); 372 RecBodyP body = folderView->fetchBody(mail);
337 vm->setBody( body ); 373 vm->setBody( body );
338 vm->setMail( mail ); 374 vm->setMail( mail );
339} 375}
340void OpieMail::displayNextMail(ViewMail * vm) 376void OpieMail::displayNextMail(ViewMail * vm)
341{ 377{
342 QListViewItem*item = mailView->currentItem(); 378 QListViewItem*item = mailView->currentItem();
343 if (!item) return; 379 if (!item) return;
344 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 380 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
345 item = item->itemBelow(); 381 item = item->itemBelow();
346 if (!item) { 382 if (!item) {
347 vm->setCaption(i18n("End of List" )); 383 vm->setCaption(i18n("End of List" ));
348 return; 384 return;
349 } 385 }
350 mailView->setCurrentItem(item); 386 mailView->setCurrentItem(item);
351 RecMailP mail = ((MailListViewItem*)item)->data(); 387 RecMailP mail = ((MailListViewItem*)item)->data();
352 RecBodyP body = folderView->fetchBody(mail); 388 RecBodyP body = folderView->fetchBody(mail);
353 vm->setBody( body ); 389 vm->setBody( body );
354 vm->setMail( mail ); 390 vm->setMail( mail );
355} 391}
356void OpieMail::displayMail() 392void OpieMail::displayMail()
357{ 393{
358 QListViewItem*item = mailView->currentItem(); 394 QListViewItem*item = mailView->currentItem();
359 if (!item) return; 395 if (!item) return;
360 RecMailP mail = ((MailListViewItem*)item)->data(); 396 RecMailP mail = ((MailListViewItem*)item)->data();
361 RecBodyP body = folderView->fetchBody(mail); 397 RecBodyP body = folderView->fetchBody(mail);
362 ViewMail readMail( this,"", Qt::WType_Modal ); 398 ViewMail readMail( this,"", Qt::WType_Modal );
363 readMail.setBody( body ); 399 readMail.setBody( body );
364 readMail.setMail( mail ); 400 readMail.setMail( mail );
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp
index 767a369..726f540 100644
--- a/kmicromail/viewmail.cpp
+++ b/kmicromail/viewmail.cpp
@@ -332,98 +332,101 @@ void ViewMail::setMail(const RecMailP&mail )
332} 332}
333 333
334 334
335 335
336ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 336ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
337 : ViewMailBase(parent, name, fl), _inLoop(false) 337 : ViewMailBase(parent, name, fl), _inLoop(false)
338{ 338{
339 m_gotBody = false; 339 m_gotBody = false;
340 deleted = false; 340 deleted = false;
341 sourceOn = false; 341 sourceOn = false;
342 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 342 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
343 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 343 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
344 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 344 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
345 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 345 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
346 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 346 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
347 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) ); 347 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) );
348 connect( viewSource, SIGNAL( activated() ), SLOT( slotViewSource() ) ); 348 connect( viewSource, SIGNAL( activated() ), SLOT( slotViewSource() ) );
349 connect( downloadMail, SIGNAL( activated() ), SIGNAL( signalDownloadMail() ) ); 349 connect( downloadMail, SIGNAL( activated() ), SIGNAL( signalDownloadMail() ) );
350 350
351 attachments->setEnabled(m_gotBody); 351 attachments->setEnabled(m_gotBody);
352 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 352 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
353 353
354 readConfig(); 354 readConfig();
355 attachments->setSorting(-1); 355 attachments->setSorting(-1);
356} 356}
357 357
358void ViewMail::readConfig() 358void ViewMail::readConfig()
359{ 359{
360 360
361 setFont ( KOPrefs::instance()->mReadFont ); 361 setFont ( KOPrefs::instance()->mReadFont );
362 m_showHtml = KOPrefs::instance()->mViewAsHtml; 362 m_showHtml = KOPrefs::instance()->mViewAsHtml;
363 showHtml->setOn( m_showHtml ); 363 showHtml->setOn( m_showHtml );
364} 364}
365 365
366void ViewMail::setText() 366void ViewMail::setText()
367{ 367{
368 368
369 viewSource->setText(i18n("View Source")); 369 viewSource->setText(i18n("View Source"));
370 sourceOn = false; 370 sourceOn = false;
371 QString toString; 371 QString toString;
372 QString ccString; 372 QString ccString;
373 QString bccString; 373 QString bccString;
374 374
375 375
376 toString = m_mail2[0].join(","); 376 toString = m_mail2[0].join(",");
377 ccString = m_mail2[1].join(","); 377 ccString = m_mail2[1].join(",");
378 bccString = m_mail2[2].join(","); 378 bccString = m_mail2[2].join(",");
379 379
380 380#ifdef DESKTOP_VERSION
381 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); 381 setCaption( i18n("Size: ")+m_recMail->MsgsizeString()+" - "+i18n("E-Mail by %1").arg( m_mail[0] ) );
382#else
383 setCaption( m_recMail->MsgsizeString()+" - "+m_mail[0] );
384#endif
382 385
383 m_mailHtml = "<html><body>" 386 m_mailHtml = "<html><body>"
384 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 387 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
385 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 388 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
386 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 389 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
387 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 390 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
388 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 391 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
389 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 392 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
390 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + 393 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] +
391 "</td></tr></table><font>"; 394 "</td></tr></table><font>";
392 395
393 if ( !m_showHtml ) 396 if ( !m_showHtml )
394 { 397 {
395 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 398 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
396 } 399 }
397 else 400 else
398 { 401 {
399 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 402 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
400 } 403 }
401 // remove later in favor of a real handling 404 // remove later in favor of a real handling
402 m_gotBody = true; 405 m_gotBody = true;
403} 406}
404 407
405 408
406ViewMail::~ViewMail() 409ViewMail::~ViewMail()
407{ 410{
408 m_recMail->Wrapper()->cleanMimeCache(); 411 m_recMail->Wrapper()->cleanMimeCache();
409 hide(); 412 hide();
410} 413}
411 414
412void ViewMail::hide() 415void ViewMail::hide()
413{ 416{
414 QWidget::hide(); 417 QWidget::hide();
415 418
416 if (_inLoop) 419 if (_inLoop)
417 { 420 {
418 _inLoop = false; 421 _inLoop = false;
419 qApp->exit_loop(); 422 qApp->exit_loop();
420 423
421 } 424 }
422 425
423} 426}
424 427
425void ViewMail::exec() 428void ViewMail::exec()
426{ 429{
427 show(); 430 show();
428 431
429 if (!_inLoop) 432 if (!_inLoop)