20 const string cachefilename = path +
"/bincimap-cache";
21 FILE *fp = fopen(cachefilename.c_str(),
"r");
23 uidvalidity = time(0);
34 uidvalidity = time(0);
45 char cacheFileVersionBuffer[512];
46 unsigned int readUidValidity;
47 unsigned int readUidNext;
49 if (sscanf(
inputBuffer,
"%s %u %u", cacheFileVersionBuffer, &readUidValidity, &readUidNext) != 3
50 || strcmp(cacheFileVersionBuffer,
BINC_CACHE) != 0) {
53 uidvalidity = time(0);
61 uidnext = readUidNext;
62 uidvalidity = readUidValidity;
65 unsigned int readSize;
66 unsigned int readInternalDate;
72 &readInternalDate, &readSize, readUnique) != 4) {
75 uidvalidity = time(0);
83 vector<string> customFlags;
86 for (
int i = 0; flagStart != 0 && *flagStart !=
'\0' && i < 4; ++i) {
87 flagStart = strchr(flagStart,
' ');
90 while (flagStart && *flagStart ==
' ')
96 char *lastOffset = flagStart;
97 flagStart = strchr(flagStart,
' ');
103 customFlags.push_back(lastOffset);
106 while (flagStart && *flagStart !=
'\0' && *flagStart ==
' ')
114 if (index.
find(readUnique) == 0) {
115 for (vector<string>::const_iterator it = customFlags.begin();
116 it != customFlags.end(); ++it) {
117 string tmpFlag = *it;
118 trim(tmpFlag,
" \n");
129 index.
insert(readUnique, readUID);
133 sort(oldCustomFlags.begin(), oldCustomFlags.end());
134 sort(customFlags.begin(), customFlags.end());
135 if (oldCustomFlags != customFlags) {
137 for (vector<string>::const_iterator it = customFlags.begin();
138 it != customFlags.end(); ++it) {
139 string tmpFlag = *it;
140 trim(tmpFlag,
" \n");
void add(MaildirMessage &m)
ReadCacheResult readCache(void)
void insert(const std::string &unique, unsigned int uid, const std::string &fileName="")
MaildirIndexItem * find(const std::string &unique)
The MaildirMessage class provides an interface for IMAP messages.
void setUnique(const std::string &s_in)
void setInternalDate(time_t internaldate)
std::vector< std::string > getCustomFlags(void) const
void setUID(unsigned int uid)
void setCustomFlag(const std::string &flag)
void resetCustomFlags(void)
void setSize(unsigned int size)
void setInternalFlag(unsigned char flags)
Declaration of miscellaneous convertion functions.
Declaration of the Maildir class.
void trim(std::string &s_in, const std::string &chars=" \t\r\n")
std::stack< int > inputBuffer