kioslave/mbox
24 #include <kio/global.h>
30 #include <QTextStream>
40 m_only_new( onlynew ),
41 m_savetime( savetime ),
43 m_prev_status( false ),
46 if(
m_info->type() == UrlInfo::invalid ) {
50 if( !open( savetime ) ) {
54 if(
m_info->type() == UrlInfo::message ) {
68 return m_current_line;
82 m_current_line = m_stream->readLine();
83 m_atend = m_current_line.isNull();
86 m_prev_status = m_status;
91 if( m_current_line.left( 5 ) ==
"From " ) {
92 m_current_id = m_current_line;
93 m_prev_status = m_status;
97 }
else if( m_only_new ) {
98 if( m_header && m_current_line.left( 7 ) ==
"Status:" &&
99 ! m_current_line.contains(
"U" ) && ! m_current_line.contains(
"N" ) ) {
104 if( m_current_line.trimmed().isEmpty() ) {
117 while( !m_atend && m_current_id !=
id ) {
121 return m_current_id == id;
126 unsigned int result = m_current_line.length();
133 result += m_current_line.length();
145 m_stream->device()->reset();
146 m_atend = m_stream->atEnd();
154 return m_atend || (
m_info->type() == UrlInfo::message && m_current_id !=
m_info->id() );
159 return !m_only_new || m_prev_status;
162 bool ReadMBox::open(
bool savetime )
165 QFileInfo info(
m_info->filename() );
167 m_prev_time =
new utimbuf;
168 m_prev_time->actime = info.lastRead().toTime_t();
169 m_prev_time->modtime = info.lastModified().toTime_t();
176 m_file =
new QFile(
m_info->filename() );
177 if( !m_file->open( QIODevice::ReadOnly ) ) {
182 m_stream =
new QTextStream( m_file );
188 void ReadMBox::close()
194 delete m_stream; m_stream = 0;
196 delete m_file; m_file = 0;
199 utime( QFile::encodeName(
m_info->filename() ), m_prev_time );
200 delete m_prev_time; m_prev_time = 0;
MBoxProtocol *const m_mbox
A instance of the parent protocol, meant to throw errors if neccesairy.
void emitError(int _errno, const QString &arg)
Through this functions, other class which have an instance to this class (classes which are part of k...
bool atEnd() const
Returns true if the cursor is at EOF.
bool inListing() const
Return true if the message is a new message, or all messages are listed.
This class can be used to lock files when implemented.
bool searchMessage(const QString &id)
This function search the file for a certain id.
QString currentLine() const
This functions return the current line.
bool nextLine()
This function reads the next line.
This class is the main class and implements all function which can be called through the user.
unsigned int skipMessage()
Skips all lines which belongs to the current message.
ReadMBox(const UrlInfo *info, MBoxProtocol *parent, bool onlynew=false, bool savetime=false)
Constructor.
void rewind()
Sets the cursor back to the beginning of the file.
QString currentID() const
This function returns the current id.
const UrlInfo *const m_info
This can be used to get information about the file.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 28 2020 00:00:00 by
doxygen 1.8.18 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.