1 line
330 KiB
C
1 line
330 KiB
C
|
/* Copyright (c) 2017, Computer History Museum
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to
the limitations in the disclaimer below) provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. */
/* Copyright (c) 1998 by QUALCOMM Incorporated */
#define FILE_NUM 114
#ifdef IMAP
/**********************************************************************
* imapDownload.c
*
* This file contains the functions that download messages and
* message bits from the server.
**********************************************************************/
#include "imapdownload.h"
/* structs and stuff ... */
#define IMAP_SEEN_STRING_FLAG "\\Seen"
#define IMAP_DELETED_STRING_FLAG "\\Deleted"
#define IMAP_FLAGGED_STRING_FLAG "\\Flagged"
#define IMAP_ANSWERED_STRING_FLAG "\\Answered"
#define IMAP_DRAFT_STRING_FLAG "\\Draft"
unsigned char *dashes = "\p--";
// for message decoding
LineIOP Lip;
long gIMAPMsgEnd;
// download error codes
enum
{
IMAPParamErr=1,
IMAPOperationAlreadyUnderwayErr,
IMAPResyncFailed
};
// global handle to list of pending deliveries
DeliveryNodeHandle gDeliveryQueue = nil;
// global handle of uids that need updating on screen
UpdateNodeHandle gWindowUpdates = nil;
// global IMAP Stream for FILTERING only
IMAPStreamPtr gFilterStream = nil;
// global pershandle for FILTERING only
PersHandle gFilterPers = nil;
// global flag to turn off progress messages
Boolean gFilteringUnderway = false;
long gManualFilteringUnderway = false;
// global list of changes needed to be made to POP mailboxes
IMAPAppendHandle gSpoolData = nil;
Boolean gSpoolDataLocked = false;
// globals indicating what mailbox is being filtered
TOCHandle gFilterTocH;
short gNumUnfiltered;
Boolean gFilteringCancelled;
// global indicating incremental searches need to be updated
Boolean gUpdateIncrementalSearches;
// This driver reads messages chunk by chunk from an IMAP server
static void StreamAppendDriverInit(STRING *s, void *data, unsigned long size);
static char StreamAppendDriverNext(STRING *s);
static void StreamAppendDriverSetpos(STRING *s, unsigned long i);
STRINGDRIVER StreamAppendDriver =
{
StreamAppendDriverInit,
StreamAppendDriverNext,
StreamAppendDriverSetpos
};
// STRINGDataStruct. Contains the data necessary for a STRING to connect and fetch a message from the source server
typedef struct STRINGDataStruct STRINGDataStruct, *STRINGDataStructPtr;
struct STRINGDataStruct
{
unsigned long uid; // uid of message to fetch
UPtr buffer; // buffer to store partial fetch in
long bufferSize; // size of buffer
long bytesRead; // number of bytes read
IMAPStreamPtr im
|