00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "filterlogentry.h"
00019
00020 FilterLogEntry::FilterLogEntry()
00021 {
00022
00023 sentDateTime.setDate( QDate( 2007, 11, 7 ) );
00024 sentDateTime.setTime( QTime( 19, 05 ) );
00025 act = FActNone;
00026 }
00027
00028 FilterLogEntry::FilterLogEntry( FilterAction_Type action, const KDateTime& dateTime, const QString& sender, const QString& account, const QString& subject, const QString& mailbox, KindOfMailDeleting kindDelete, const QString& filter )
00029 : act( action ), sentDateTime( dateTime ), sender( sender ), account( account ), subject( subject ), mailbox( mailbox ), kindDel( kindDelete ), filter( filter )
00030 {
00031 }
00032
00033 FilterLogEntry::~FilterLogEntry()
00034 {
00035 }
00036
00037 void FilterLogEntry::print()
00038 {
00039 QString strAction;
00040 switch( act )
00041 {
00042 case FActPass : strAction = "Passed"; break;
00043 case FActDelete : strAction = "Deleted"; break;
00044 case FActMark : strAction = "Marked"; break;
00045 case FActSpamcheck : strAction = "forwarded to check for spam"; break;
00046 case FActMove : strAction = QString( "moved to %1" ).arg( mailbox); break;
00047 case FActNone : strAction = "no Action (THIS IS AN ERROR!)"; break;
00048 default : strAction = "ERROR! UNKNOWN ACTION"; break;
00049 }
00050
00051 kdDebug() << sentDateTime.toString( KDateTime::LocalDate ) << ";" << account << ";" << sender << ";" << subject << ";" << strAction << endl;
00052 }
00053
00054 FilterLogEntry::FilterLogEntry(const FilterLogEntry & ent)
00055 {
00056 this->sentDateTime = ent.sentDateTime;
00057 this->account = ent.account;
00058 this->sender = ent.sender;
00059 this->subject = ent.subject;
00060 this->act = ent.act;
00061 this->mailbox = ent.mailbox;
00062 this->kindDel = ent.kindDel;
00063 this->filter = ent.filter;
00064 }
00065
00066 FilterLogEntry& FilterLogEntry::operator=( const FilterLogEntry & ent )
00067 {
00068 if( this == &ent ) return *this;
00069
00070 this->sentDateTime = ent.sentDateTime;
00071 this->account = ent.account;
00072 this->sender = ent.sender;
00073 this->subject = ent.subject;
00074 this->mailbox = ent.mailbox;
00075 this->act = ent.act;
00076 this->kindDel = ent.kindDel;
00077 this->filter = ent.filter;
00078
00079 return *this;
00080 }
00081
00082 bool FilterLogEntry::isOlder( uint days )
00083 {
00084 return sentDateTime.date().addDays( days ) < QDate::currentDate();
00085 }
00086
00087 bool FilterLogEntry::operator== ( const FilterLogEntry& ent ) const
00088 {
00089 return sentDateTime == ent.sentDateTime;
00090 }
00091
00092 bool FilterLogEntry::operator!=( const FilterLogEntry& ent ) const
00093 {
00094 return sentDateTime != ent.sentDateTime;
00095 }
00096
00097 bool FilterLogEntry::operator>( const FilterLogEntry& ent ) const
00098 {
00099 return sentDateTime > ent.sentDateTime;
00100 }
00101
00102 bool FilterLogEntry::operator>=( const FilterLogEntry& ent ) const
00103 {
00104 return sentDateTime >= ent.sentDateTime;
00105 }
00106
00107 bool FilterLogEntry::operator<( const FilterLogEntry& ent ) const
00108 {
00109 return sentDateTime < ent.sentDateTime;
00110 }
00111
00112 bool FilterLogEntry::operator<=( const FilterLogEntry & ent ) const
00113 {
00114 return sentDateTime <= ent.sentDateTime;
00115 }
00116
00117 void FilterLogEntry::save( QDomDocument& doc, QDomElement& parent )
00118 {
00119
00120 QDomElement elem = doc.createElement( LOG_ENTRY_ELEMENT );
00121 elem.setAttribute( LOG_ENTRY_ATTRIBUTE_DATETIME, sentDateTime.toString( KDateTime::ISODate ) );
00122 elem.setAttribute( LOG_ENTRY_ATTRIBUTE_SENDER, sender );
00123 elem.setAttribute( LOG_ENTRY_ATTRIBUTE_ACCOUNT, account );
00124 elem.setAttribute( LOG_ENTRY_ATTRIBUTE_SUBJECT, subject );
00125 if( kindDel == DelFilter ) {
00126 elem.setAttribute( LOG_ENTRY_ATTRIBUTE_KIND_DELETE, LOG_ENTRY_VALUE_KIND_DELETE_FILTER );
00127 } else {
00128 elem.setAttribute( LOG_ENTRY_ATTRIBUTE_KIND_DELETE, LOG_ENTRY_VALUE_KIND_DELETE_MANUAL );
00129 }
00130 elem.setAttribute( LOG_ENTRY_ATTRIBUTE_FILTER, filter );
00131
00132
00133 parent.appendChild( elem );
00134 }
00135
00136 KDateTime FilterLogEntry::getDate( ) const
00137 {
00138 return sentDateTime;
00139 }
00140
00141 QString FilterLogEntry::getSender( ) const
00142 {
00143 return sender;
00144 }
00145
00146 QString FilterLogEntry::getAccount( ) const
00147 {
00148 return account;
00149 }
00150
00151 QString FilterLogEntry::getSubject( ) const
00152 {
00153 return subject;
00154 }
00155
00156 QString FilterLogEntry::getMailbox( ) const
00157 {
00158 return mailbox;
00159 }
00160
00161 int FilterLogEntry::compare( const FilterLogEntry& other, LogViewSort property ) const
00162 {
00163 switch( property ) {
00164
00165 case( LogViewSortKind ) : {
00166
00167 if( getKindOfDeleting() == other.getKindOfDeleting() ) return 0;
00168 else if( getKindOfDeleting() > other.getKindOfDeleting() ) return 1;
00169 else return -1;
00170 }
00171
00172 case( LogViewSortDate ) : {
00173
00174 if( getDate() == other.getDate() ) return 0;
00175 else if( getDate() > other.getDate() ) return 1;
00176 else return -1;
00177
00178 }
00179
00180 case( LogViewSortFrom ) : {
00181
00182 return QString::localeAwareCompare( getSender(), other.getSender() );
00183 }
00184
00185 case( LogViewSortAccount ) : {
00186
00187 return QString::localeAwareCompare( getAccount(), other.getAccount() );
00188 }
00189
00190 case( LogViewSortSubject ) : {
00191
00192 return QString::localeAwareCompare( getSubject(), other.getSubject() );
00193 }
00194
00195 case( LogViewSortMailbox ) : {
00196
00197 return QString::localeAwareCompare( getMailbox(), other.getMailbox() );
00198 }
00199
00200 default : {
00201
00202 if( getDate() == other.getDate() ) return 0;
00203 else if( getDate() > other.getDate() ) return 1;
00204 else return -1;
00205
00206 }
00207
00208 }
00209 }
00210
00211 KindOfMailDeleting FilterLogEntry::getKindOfDeleting() const
00212 {
00213 return kindDel;
00214 }
00215
00216 QString FilterLogEntry::getFilter() const
00217 {
00218 return filter;
00219 }
00220