Author: czeidler Date: 2011-02-11 00:42:27 +0100 (Fri, 11 Feb 2011) New Revision: 40437 Changeset: http://dev.haiku-os.org/changeset/40437 Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPInboundProtocol.cpp haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp Log: Initalize array for reading the uid string attribute. More cleanup. Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPInboundProtocol.cpp =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPInboundProtocol.cpp 2011-02-10 22:03:51 UTC (rev 40436) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPInboundProtocol.cpp 2011-02-10 23:42:27 UTC (rev 40437) @@ -199,14 +199,14 @@ message->FindInt64("directory", &ref.directory); message->FindString("name", &name); ref.set_name(name); - //TODO not thread safe + fProtocol->AppendMessage(ref); break; case B_ENTRY_REMOVED: message->FindInt32("device", &nref.device); message->FindInt64("node", &nref.node); - //TODO not thread safe + fProtocol->DeleteMessage(nref); break; Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp 2011-02-10 22:03:51 UTC (rev 40436) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPHandler.cpp 2011-02-10 23:42:27 UTC (rev 40437) @@ -394,7 +394,7 @@ BString headerSize = IMAPParser::RemovePrimitiveFromLeft(extracted); headerSize = IMAPParser::ExtractNextElement(headerSize); int32 size = atoi(headerSize); - TRACE("Header size %i\n", (int)size); + status_t status = fConnectionReader.ReadToFile(size, data); if (status != B_OK) { if (!fOutData) Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp 2011-02-10 22:03:51 UTC (rev 40436) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_lib/IMAPStorage.cpp 2011-02-10 23:42:27 UTC (rev 40437) @@ -170,7 +170,7 @@ BPath filePath = fMailboxPath; filePath.Append(fileName); - TRACE("file name %s\n", filePath.Path()); + TRACE("AddNewMessage %s\n", filePath.Path()); BFile* newFile = new BFile(filePath.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); if (newFile == NULL) @@ -238,7 +238,8 @@ BPath filePath = fMailboxPath; filePath.Append(storageEntry.fileName); BEntry entry(filePath.Path()); -TRACE("delete %s\n", filePath.Path()); + TRACE("IMAPStorage::DeleteMessage %s, %ld\n", filePath.Path(), uid); + status_t status = entry.Remove(); if (status != B_OK) return status; @@ -439,8 +440,11 @@ StorageMailEntry entry; entry.fileName = ref.name; - if (ReadUniqueID(node, entry.uid) != B_OK) + if (ReadUniqueID(node, entry.uid) != B_OK) { + TRACE("IMAPStorage::_ReadFilesThread() failed to read uid %s\n", + ref.name); continue; + } if (node.ReadAttr("MAIL:server_flags", B_INT32_TYPE, 0, &entry.flags, sizeof(int32)) != sizeof(int32)) @@ -475,9 +479,11 @@ status_t IMAPStorage::ReadUniqueID(BNode& node, int32& uid) { - char uidString[256]; + const uint32 kMaxUniqueLength = 32; + char uidString[kMaxUniqueLength]; + memset(uidString, 0, kMaxUniqueLength); if (node.ReadAttr("MAIL:unique_id", B_STRING_TYPE, 0, uidString, - 256) < 0) + kMaxUniqueLength) < 0) return B_ERROR; uid = atoi(uidString); return B_OK;