27 #include <tdeio/global.h>
30 #include <tqfileinfo.h>
32 #include <tqtextstream.h>
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
44 m_current_line( new TQString( TQString() ) ),
45 m_current_id( new TQString( TQString() ) ),
48 m_only_new( onlynew ),
49 m_savetime( savetime ),
51 m_prev_status( false ),
55 if(
m_info->type() == UrlInfo::invalid )
58 if( !open( savetime ) )
61 if(
m_info->type() == UrlInfo::message )
68 delete m_current_line;
74 return *m_current_line;
87 *m_current_line = m_stream->readLine();
88 m_atend = m_current_line->isNull();
91 *m_current_id = TQString();
92 m_prev_status = m_status;
97 if( m_current_line->left( 5 ) ==
"From " )
99 *m_current_id = *m_current_line;
100 m_prev_status = m_status;
104 }
else if( m_only_new )
106 if( m_header && m_current_line->left( 7 ) ==
"Status:" &&
107 ! m_current_line->contains(
"U" ) && ! m_current_line->contains(
"N" ) )
113 if( m_current_line->stripWhiteSpace().isEmpty() )
124 while( !m_atend && *m_current_id !=
id )
127 return *m_current_id == id;
132 unsigned int result = m_current_line->length();
138 result += m_current_line->length();
148 m_stream->device()->reset();
149 m_atend = m_stream->atEnd();
157 return m_atend || (
m_info->type() == UrlInfo::message && *m_current_id !=
m_info->id() );
162 return !m_only_new || m_prev_status;
165 bool ReadMBox::open(
bool savetime )
169 TQFileInfo info(
m_info->filename() );
171 m_prev_time =
new utimbuf;
172 m_prev_time->actime = info.lastRead().toTime_t();
173 m_prev_time->modtime = info.lastModified().toTime_t();
179 m_file =
new TQFile(
m_info->filename() );
180 if( !m_file->open( IO_ReadOnly ) )
186 m_stream =
new TQTextStream( m_file );
192 void ReadMBox::close()
197 delete m_stream; m_stream = 0;
199 delete m_file; m_file = 0;
202 utime( TQFile::encodeName(
m_info->filename() ), m_prev_time );