~ubuntu-branches/ubuntu/trusty/kdepimlibs/trusty

« back to all changes in this revision

Viewing changes to kioslave/mbox/readmbox.h

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-11-23 17:36:44 UTC
  • mfrom: (1.1.102)
  • Revision ID: package-import@ubuntu.com-20131123173644-p5ow94192ezsny8g
Tags: 4:4.11.80-0ubuntu1
[ Rohan Garg ]
* New upstream beta release
  - Bump akonadi requirement to 1.10.45
  - Update install files
  - Update symbols

[ Philip Muškovac ]
* kdepimlibs-dev/-dbg breaks/replaces kdepim-runtime/-dbg (<< 4:4.11.80)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
class ReadMBox : public MBoxFile
39
39
{
40
40
public:
41
 
        /**
42
 
         * Constructor
43
 
         *
44
 
         * @param info The information of the file to read
45
 
         * @param parent The instance of the parent MBoxProtocol.
46
 
         * @param onlynew Only read new messages from the MBox file.
47
 
         * @param savetime If true, the atime of the mbox-file is preserved (note that this touch the ctime).
48
 
         */
49
 
        ReadMBox( const UrlInfo* info, MBoxProtocol* parent, bool onlynew = false, bool savetime = false );
50
 
 
51
 
        /**
52
 
         * Destructor
53
 
         */
54
 
        ~ReadMBox();
55
 
 
56
 
        /**
57
 
         * This functions return the current line
58
 
         * @return The line last read, or QString() if there wasn't such last line
59
 
         */
60
 
        QString currentLine() const;
61
 
 
62
 
        /**
63
 
         * This function returns the current id. The id is the first line of an email,
64
 
         * and is used in filenaming. The id normally starts with "From ".
65
 
         * @return The current ID, or QString() if no id was found yet.
66
 
         */
67
 
        QString currentID() const;
68
 
 
69
 
        /**
70
 
         * This function reads the next line. The next line can be read by the currentLine()
71
 
         * function call.
72
 
         *
73
 
         * @return true if succesfull, otherwise false.
74
 
         */
75
 
        bool nextLine();
76
 
 
77
 
        /**
78
 
         * This function search the file for a certain id.
79
 
         * If not found, the position is EOF.
80
 
         * @param id The id of the message to be found.
81
 
         * @return true if the message was found, false otherwise.
82
 
         */
83
 
        bool searchMessage( const QString& id );
84
 
 
85
 
        /**
86
 
         * Skips all lines which belongs to the current message. The cursor is on the first line
87
 
         * of a new message message at the end of this function, or at EOF if the cursor was already
88
 
         * on the last message.
89
 
         * @return The number of bytes read while skipping the message.
90
 
         */
91
 
        unsigned int skipMessage();
92
 
 
93
 
        /**
94
 
         * Sets the cursor back to the beginning of the file
95
 
         */
96
 
        void rewind();
97
 
 
98
 
        /**
99
 
         * Returns true if the cursor is at EOF.
100
 
         * @return true if and only if the cursor is at EOF.
101
 
         */
102
 
        bool atEnd() const;
103
 
 
104
 
        /**
105
 
         * Return true if the message is a new message, or all messages are listed
106
 
         * @return true if it must be listed
107
 
         */
108
 
        bool inListing() const;
109
 
private:
110
 
        /**
111
 
         * Opens a file
112
 
         * @return true Returns true if opening was successful.
113
 
         */
114
 
        bool open( bool savetime );
115
 
 
116
 
        /**
117
 
         * Closes a file.
118
 
         */
119
 
        void close();
120
 
 
121
 
private:
122
 
        QFile* m_file;
123
 
        QTextStream* m_stream;
124
 
        QString m_current_line;
125
 
        QString m_current_id;
126
 
        bool m_atend;
127
 
 
128
 
        struct utimbuf* m_prev_time;
129
 
 
130
 
        bool m_only_new, m_savetime;
131
 
 
132
 
        bool m_status, m_prev_status, m_header;
 
41
        /**
 
42
         * Constructor
 
43
         *
 
44
         * @param info The information of the file to read
 
45
         * @param parent The instance of the parent MBoxProtocol.
 
46
         * @param onlynew Only read new messages from the MBox file.
 
47
         * @param savetime If true, the atime of the mbox-file is preserved (note that this touch the ctime).
 
48
         */
 
49
        ReadMBox( const UrlInfo* info, MBoxProtocol* parent, bool onlynew = false, bool savetime = false );
 
50
 
 
51
        /**
 
52
         * Destructor
 
53
         */
 
54
        ~ReadMBox();
 
55
 
 
56
        /**
 
57
         * This functions return the current line
 
58
         * @return The line last read, or QString() if there wasn't such last line
 
59
         */
 
60
        QString currentLine() const;
 
61
 
 
62
        /**
 
63
         * This function returns the current id. The id is the first line of an email,
 
64
         * and is used in filenaming. The id normally starts with "From ".
 
65
         * @return The current ID, or QString() if no id was found yet.
 
66
         */
 
67
        QString currentID() const;
 
68
 
 
69
        /**
 
70
         * This function reads the next line. The next line can be read by the currentLine()
 
71
         * function call.
 
72
         *
 
73
         * @return true if succesfull, otherwise false.
 
74
         */
 
75
        bool nextLine();
 
76
 
 
77
        /**
 
78
         * This function search the file for a certain id.
 
79
         * If not found, the position is EOF.
 
80
         * @param id The id of the message to be found.
 
81
         * @return true if the message was found, false otherwise.
 
82
         */
 
83
        bool searchMessage( const QString& id );
 
84
 
 
85
        /**
 
86
         * Skips all lines which belongs to the current message. The cursor is on the first line
 
87
         * of a new message message at the end of this function, or at EOF if the cursor was already
 
88
         * on the last message.
 
89
         * @return The number of bytes read while skipping the message.
 
90
         */
 
91
        unsigned int skipMessage();
 
92
 
 
93
        /**
 
94
         * Sets the cursor back to the beginning of the file
 
95
         */
 
96
        void rewind();
 
97
 
 
98
        /**
 
99
         * Returns true if the cursor is at EOF.
 
100
         * @return true if and only if the cursor is at EOF.
 
101
         */
 
102
        bool atEnd() const;
 
103
 
 
104
        /**
 
105
         * Return true if the message is a new message, or all messages are listed
 
106
         * @return true if it must be listed
 
107
         */
 
108
        bool inListing() const;
 
109
private:
 
110
        /**
 
111
         * Opens a file
 
112
         * @return true Returns true if opening was successful.
 
113
         */
 
114
        bool open( bool savetime );
 
115
 
 
116
        /**
 
117
         * Closes a file.
 
118
         */
 
119
        void close();
 
120
 
 
121
private:
 
122
        QFile* m_file;
 
123
        QTextStream* m_stream;
 
124
        QString m_current_line;
 
125
        QString m_current_id;
 
126
        bool m_atend;
 
127
 
 
128
        struct utimbuf* m_prev_time;
 
129
 
 
130
        bool m_only_new, m_savetime;
 
131
 
 
132
        bool m_status, m_prev_status, m_header;
133
133
};
134
134
#endif