Exemple #1
0
/*!	Writes UID, and flags to the message, and notifies the protocol that a
	message has been fetched. This method also closes the \a file passed in.
*/
void
IMAPFolder::MessageStored(entry_ref& ref, BFile& file, uint32 fetchFlags,
	uint32 uid, uint32 flags)
{
	_WriteUniqueIDValidity(file);
	_WriteUniqueID(file, uid);
	if ((fetchFlags & IMAP::kFetchFlags) != 0)
		_WriteFlags(file, flags);

	BMessage attributes;
	_IMAPToMailFlags(flags, attributes);

	fProtocol.MessageStored(*this, ref, file, fetchFlags, attributes);
	file.Unset();

	fRefMap.insert(std::make_pair(uid, ref));

	if (uid > fLastUID) {
		// Update last known UID
		fLastUID = uid;

		BNode directory(&fRef);
		status_t status = _WriteUInt32(directory, kLastUIDAttribute, uid);
		if (status != B_OK) {
			fprintf(stderr, "IMAP: Could not write last UID for mailbox "
				"%s: %s\n", fMailboxName.String(), strerror(status));
		}
	}
}
Exemple #2
0
status_t
IMAPStorage::AddNewMessage(int32 uid, int32 flags, BPositionIO** file)
{
    if (file != NULL)
        *file = NULL;
    // TODO: make sure there is not a valid mail with this name
    BString fileName = "Downloading file... uid: ";
    fileName << uid;

    BPath filePath = fMailboxPath;
    filePath.Append(fileName);
    TRACE("AddNewMessage %s\n", filePath.Path());
    BFile* newFile = new BFile(filePath.Path(), B_READ_WRITE | B_CREATE_FILE
                               | B_ERASE_FILE);
    if (newFile == NULL)
        return B_NO_MEMORY;

    StorageMailEntry storageEntry;
    storageEntry.uid = uid;
    storageEntry.flags = flags;
    storageEntry.fileName = fileName;
    newFile->GetNodeRef(&storageEntry.nodeRef);

    if (_WriteUniqueID(*newFile, uid) != B_OK) {
        delete newFile;
        return B_ERROR;
    }

    status_t status = _WriteFlags(flags, *newFile);
    if (status != B_OK) {
        delete newFile;
        return status;
    }

    if (file)
        *file = newFile;
    else
        delete newFile;
    fMailEntryMap[uid] = storageEntry;
    return B_OK;
}