mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 17:59:34 +00:00
Bug 173634 flawfinder warnings in xp_str.h: kill xp_str.h, xp_path.h and clean out old/dead defines/code
r=mkaply sr=alecf Removing dead code guarded by: BUG_21013 MORK_USE_XP_STDLIB notdef OLDWAY UNREADY_CODE Removing *Apple*Decode* files which aren't being built
This commit is contained in:
parent
603ae79c1b
commit
1f6bfed465
@ -160,7 +160,6 @@ extern void mork_assertion_signal(const char* inMessage);
|
||||
#define MORK_LIB_IMPL(return) return /*implementation return declaration*/
|
||||
|
||||
// { %%%%% begin standard c utility methods %%%%%
|
||||
/*define MORK_USE_XP_STDLIB 1*/
|
||||
|
||||
#if defined(MORK_WIN) || defined(MORK_UNIX) || defined(MORK_MAC) || defined(MORK_BEOS) || defined(MORK_OS2)
|
||||
#define MORK_USE_C_STDLIB 1
|
||||
@ -197,18 +196,6 @@ MORK_LIB(mork_size) mork_strlen(const void* inString);
|
||||
#define MORK_STRLEN(string) mork_strlen(string)
|
||||
#endif /*MORK_PROVIDE_STDLIB*/
|
||||
|
||||
#ifdef MORK_USE_XP_STDLIB
|
||||
#define MORK_MEMCMP(src1,src2,size) XP_MEMCMP(src1,src2,size)
|
||||
#define MORK_MEMCPY(dest,src,size) XP_MEMCPY(dest,src,size)
|
||||
#define MORK_MEMMOVE(dest,src,size) XP_MEMMOVE(dest,src,size)
|
||||
#define MORK_MEMSET(dest,byte,size) XP_MEMSET(dest,byte,size)
|
||||
#define MORK_STRCPY(dest,src) XP_STRCPY(dest,src)
|
||||
#define MORK_STRCMP(one,two) XP_STRCMP(one,two)
|
||||
#define MORK_STRNCMP(one,two,length) XP_STRNCMP(one,two,length)
|
||||
#define MORK_STRLEN(string) XP_STRLEN(string)
|
||||
#endif /*MORK_USE_XP_STDLIB*/
|
||||
|
||||
|
||||
// } %%%%% end standard c utility methods %%%%%
|
||||
|
||||
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
|
||||
|
@ -600,96 +600,6 @@ nsresult nsMsgSearchNewsEx::SaveProfile (const char *profileName)
|
||||
return err;
|
||||
}
|
||||
#endif // DOING_PROFILES
|
||||
#if OLDWAY
|
||||
// Callback from libnet
|
||||
SEARCH_API void MSG_AddNewsSearchHit (MWContext *context, const char *resultLine)
|
||||
{
|
||||
MSG_SearchFrame *frame = MSG_SearchFrame::FromContext (context);
|
||||
nsMsgSearchNewsEx *adapter = (nsMsgSearchNewsEx *) frame->GetRunningAdapter();
|
||||
if (adapter)
|
||||
{
|
||||
MessageHdrStruct hdr;
|
||||
XP_BZERO(&hdr, sizeof(hdr));
|
||||
|
||||
// Here we make the SEARCH result compatible with xover conventions. In SEARCH, the
|
||||
// group name and a ':' precede the article number, so try to skip over this stuff
|
||||
// before asking NeoMessageHdr to parse it
|
||||
char *xoverCompatLine = XP_STRCHR(resultLine, ':');
|
||||
if (xoverCompatLine)
|
||||
xoverCompatLine++;
|
||||
else
|
||||
xoverCompatLine = (char*) resultLine; //### casting away const
|
||||
|
||||
if (NeoMessageHdr::ParseLine ((char*) xoverCompatLine, &hdr)) //### casting away const
|
||||
{
|
||||
if (hdr.m_flags & kHasRe) // hack around which kind of flag we actually got
|
||||
{
|
||||
hdr.m_flags &= !kHasRe;
|
||||
hdr.m_flags |= MSG_FLAG_HAS_RE;
|
||||
}
|
||||
adapter->ReportHit (&hdr, XP_STRTOK((char*) resultLine, ":")); //### casting away const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SEARCH_API nsresult MSG_SaveProfileStatus (MSG_Pane *searchPane, PRBool *cmdEnabled)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
|
||||
NS_ABORT_IF_FALSE(cmdEnabled, "cmdEnabled cannot be NULL");
|
||||
if (cmdEnabled)
|
||||
{
|
||||
*cmdEnabled = PR_FALSE;
|
||||
MSG_SearchFrame *frame = MSG_SearchFrame::FromPane (searchPane);
|
||||
if (frame)
|
||||
*cmdEnabled = frame->GetSaveProfileStatus();
|
||||
}
|
||||
else
|
||||
err = NS_ERROR_NULL_POINTER;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
SEARCH_API nsresult MSG_SaveProfile (MSG_Pane *searchPane, const char * profileName)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
|
||||
#ifdef _DEBUG
|
||||
PRBool enabled = PR_FALSE;
|
||||
MSG_SaveProfileStatus (searchPane, &enabled);
|
||||
NS_ENSURE_TRUE(enabled, SearchError_ScopeAgreement);
|
||||
#endif
|
||||
|
||||
if (profileName)
|
||||
{
|
||||
MSG_SearchFrame *frame = MSG_SearchFrame::FromPane (searchPane);
|
||||
NS_ASSERTION(frame, "frame cannot be NULL");
|
||||
if (frame)
|
||||
{
|
||||
nsMsgSearchNewsEx *adapter = frame->GetProfileAdapter();
|
||||
NS_ASSERTION(adapter, "adaptor cannot be NULL");
|
||||
if (adapter)
|
||||
err = adapter->SaveProfile (profileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
err = NS_ERROR_NULL_POINTER;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
SEARCH_API int MSG_AddProfileGroup (MSG_Pane *pane, MSG_NewsHost* host,
|
||||
const char *groupName)
|
||||
{
|
||||
MSG_FolderInfoNews *group =
|
||||
pane->GetMaster()->AddProfileNewsgroup(host, groupName);
|
||||
return group ? 0 : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsresult nsMsgSearchValidityManager::InitNewsTable()
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,753 +0,0 @@
|
||||
DON'T COMPILE ME!!!
|
||||
RICHIE
|
||||
RICHIE
|
||||
RICHIE OLD FE INTERFACES TO APPLEDOUBLE ENCODE/DECODE
|
||||
RICHIE
|
||||
RICHIE
|
||||
RICHIE
|
||||
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Apple Double encode/decode stream
|
||||
* ----------------------------------
|
||||
*
|
||||
* 11sep95 mym created.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "msgCore.h"
|
||||
#include "prio.h"
|
||||
|
||||
#include "nsMsgAppleDouble.h"
|
||||
#include "nsMsgAppleCodes.h"
|
||||
|
||||
#include "nsMsgBinHex.h"
|
||||
#include "m_cvstrm.h"
|
||||
|
||||
extern int MK_MSG_SAVE_ATTACH_AS;
|
||||
|
||||
#ifdef RICHIE_XP_MAC
|
||||
#pragma warn_unusedarg off
|
||||
|
||||
extern int MK_UNABLE_TO_OPEN_TMP_FILE;
|
||||
extern int MK_MIME_ERROR_WRITING_FILE;
|
||||
|
||||
/* ---------------------------------------------------------------------------------
|
||||
**
|
||||
** The codes for Apple-double encoding stream. --- it's only useful on Mac OS
|
||||
**
|
||||
** ---------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define WORKING_BUFF_SIZE 8192
|
||||
|
||||
typedef struct _AppledoubleEncodeObject
|
||||
{
|
||||
appledouble_encode_object ap_encode_obj;
|
||||
|
||||
char* buff; /* the working buff. */
|
||||
PRInt32 s_buff; /* the working buff size. */
|
||||
|
||||
RICHIE_XP_File fp; /* file to hold the encoding */
|
||||
char *fname; /* and the file name. */
|
||||
|
||||
} AppleDoubleEncodeObject;
|
||||
|
||||
/*
|
||||
Let's go "l" characters forward of the encoding for this write.
|
||||
Note:
|
||||
"s" is just a dummy paramter.
|
||||
*/
|
||||
PRIVATE int
|
||||
net_AppleDouble_Encode_Write (
|
||||
void *stream, const char* s, PRInt32 l)
|
||||
{
|
||||
int status = 0;
|
||||
AppleDoubleEncodeObject * obj = (AppleDoubleEncodeObject*)stream;
|
||||
PRInt32 count, size;
|
||||
|
||||
while (l > 0)
|
||||
{
|
||||
size = obj->s_buff * 11 / 16;
|
||||
size = PR_MIN(l, size);
|
||||
status = ap_encode_next(&(obj->ap_encode_obj),
|
||||
obj->buff,
|
||||
size,
|
||||
&count);
|
||||
if (status == noErr || status == errDone)
|
||||
{
|
||||
/*
|
||||
* we get the encode data, so call the next stream to write it to the disk.
|
||||
*/
|
||||
if (RICHIE_XP_FileWrite(obj->buff, count, obj->fp) != count)
|
||||
return errFileWrite;
|
||||
}
|
||||
|
||||
if (status != noErr ) /* abort when error / done? */
|
||||
break;
|
||||
|
||||
l -= size;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
** is the stream ready for writing?
|
||||
*/
|
||||
PRIVATE unsigned int net_AppleDouble_Encode_Ready (void *stream)
|
||||
{
|
||||
return(PR_MAX_WRITE_READY); /* always ready for writing */
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_AppleDouble_Encode_Complete (void *stream)
|
||||
{
|
||||
AppleDoubleEncodeObject * obj = (AppleDoubleEncodeObject*)stream;
|
||||
|
||||
ap_encode_end(&(obj->ap_encode_obj), false); /* this is a normal ending */
|
||||
|
||||
if (obj->fp)
|
||||
{
|
||||
RICHIE_XP_FileClose(obj->fp); /* done with the target file */
|
||||
|
||||
PR_FREEIF(obj->fname); /* and the file name too */
|
||||
}
|
||||
|
||||
PR_FREEIF(obj->buff); /* free the working buff. */
|
||||
PR_FREEIF(obj);
|
||||
}
|
||||
|
||||
PRIVATE void net_AppleDouble_Encode_Abort (void *stream, int status)
|
||||
{
|
||||
AppleDoubleEncodeObject * obj = (AppleDoubleEncodeObject*)stream;
|
||||
|
||||
ap_encode_end(&(obj->ap_encode_obj), true); /* it is an aborting exist... */
|
||||
|
||||
if (obj->fp)
|
||||
{
|
||||
RICHIE_XP_FileClose(obj->fp);
|
||||
|
||||
RICHIE_XP_FileRemove (obj->fname, xpURL); /* remove the partial file. */
|
||||
|
||||
PR_FREEIF(obj->fname);
|
||||
}
|
||||
PR_FREEIF(obj->buff); /* free the working buff. */
|
||||
PR_FREEIF(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
** fe_MakeAppleDoubleEncodeStream
|
||||
** ------------------------------
|
||||
**
|
||||
** Will create a apple double encode stream:
|
||||
**
|
||||
** -> take the filename as the input source (it needs to be a mac file.)
|
||||
** -> take a file name for the temp file we are generating.
|
||||
*/
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
fe_MakeAppleDoubleEncodeStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id,
|
||||
char* src_filename,
|
||||
char* dst_filename,
|
||||
char* separator)
|
||||
{
|
||||
AppleDoubleEncodeObject* obj;
|
||||
NET_StreamClass* stream;
|
||||
char* working_buff = NULL;
|
||||
int bSize = WORKING_BUFF_SIZE;
|
||||
|
||||
TRACEMSG(("Setting up apple encode stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
stream = new (NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
obj = new (AppleDoubleEncodeObject);
|
||||
if (obj == NULL)
|
||||
{
|
||||
PR_FREEIF (stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
while (!working_buff && (bSize >= 512))
|
||||
{
|
||||
working_buff = (char *)PR_CALLOC(bSize);
|
||||
if (!working_buff)
|
||||
bSize /= 2;
|
||||
}
|
||||
if (working_buff == NULL)
|
||||
{
|
||||
PR_FREEIF (obj);
|
||||
PR_FREEIF (stream);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
stream->name = "Apple Double Encode";
|
||||
stream->complete = (MKStreamCompleteFunc) net_AppleDouble_Encode_Complete;
|
||||
stream->abort = (MKStreamAbortFunc) net_AppleDouble_Encode_Abort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_AppleDouble_Encode_Write;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_AppleDouble_Encode_Ready;
|
||||
stream->data_object = obj;
|
||||
stream->window_id = window_id;
|
||||
|
||||
obj->fp = RICHIE_XP_FileOpen(dst_filename, xpFileToPost, RICHIE_XP_FILE_WRITE_BIN);
|
||||
if (obj->fp == NULL)
|
||||
{
|
||||
PR_FREEIF (working_buff);
|
||||
PR_FREEIF (obj);
|
||||
PR_FREEIF (stream);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
obj->fname = nsCRT::strdup(dst_filename);
|
||||
|
||||
obj->buff = working_buff;
|
||||
obj->s_buff = bSize;
|
||||
|
||||
/*
|
||||
** setup all the need information on the apple double encoder.
|
||||
*/
|
||||
ap_encode_init(&(obj->ap_encode_obj),
|
||||
src_filename, /* pass the file name of the source. */
|
||||
separator);
|
||||
|
||||
TRACEMSG(("Returning stream from NET_AppleDoubleEncoder\n"));
|
||||
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** ---------------------------------------------------------------------------------
|
||||
**
|
||||
** The codes for the Apple sigle/double decoding.
|
||||
**
|
||||
** ---------------------------------------------------------------------------------
|
||||
*/
|
||||
typedef struct AppleDoubleDecodeObject
|
||||
{
|
||||
appledouble_decode_object ap_decode_obj;
|
||||
|
||||
char* in_buff; /* the temporary buff to accumulate */
|
||||
/* the input, make sure the call to */
|
||||
/* the dedcoder engine big enough buff */
|
||||
PRInt32 bytes_in_buff; /* the count for the temporary buff. */
|
||||
|
||||
NET_StreamClass* binhex_stream; /* a binhex encode stream to convert */
|
||||
/* the decoded mac file to binhex. */
|
||||
|
||||
} AppleDoubleDecodeObject;
|
||||
|
||||
PRIVATE int
|
||||
net_AppleDouble_Decode_Write (
|
||||
void *stream, const char* s, PRInt32 l)
|
||||
{
|
||||
int status = NOERR;
|
||||
AppleDoubleDecodeObject * obj = (AppleDoubleDecodeObject*) stream;
|
||||
PRInt32 size;
|
||||
|
||||
/*
|
||||
** To force an effecient decoding, we should
|
||||
** make sure that the buff pass to the decode next is great than 1024 bytes.
|
||||
*/
|
||||
if (obj->bytes_in_buff + l > 1024)
|
||||
{
|
||||
size = 1024 - obj->bytes_in_buff;
|
||||
memcpy(obj->in_buff+obj->bytes_in_buff,
|
||||
s,
|
||||
size);
|
||||
s += size;
|
||||
l -= size;
|
||||
|
||||
status = ap_decode_next(&(obj->ap_decode_obj),
|
||||
obj->in_buff,
|
||||
1024);
|
||||
obj->bytes_in_buff = 0;
|
||||
}
|
||||
|
||||
if (l > 1024)
|
||||
{
|
||||
/* we are sure that obj->bytes_in_buff == 0 at this point. */
|
||||
status = ap_decode_next(&(obj->ap_decode_obj),
|
||||
(char *)s,
|
||||
l);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* and we are sure we will not get overflow with the buff. */
|
||||
memcpy(obj->in_buff+obj->bytes_in_buff,
|
||||
s,
|
||||
l);
|
||||
obj->bytes_in_buff += l;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
PRIVATE unsigned int
|
||||
net_AppleDouble_Decode_Ready (NET_StreamClass *stream)
|
||||
{
|
||||
return(PR_MAX_WRITE_READY); /* always ready for writing */
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void
|
||||
net_AppleDouble_Decode_Complete (void *stream)
|
||||
{
|
||||
AppleDoubleDecodeObject *obj = (AppleDoubleDecodeObject *)stream;
|
||||
|
||||
if (obj->bytes_in_buff)
|
||||
{
|
||||
|
||||
ap_decode_next(&(obj->ap_decode_obj), /* do the last calls. */
|
||||
(char *)obj->in_buff,
|
||||
obj->bytes_in_buff);
|
||||
obj->bytes_in_buff = 0;
|
||||
}
|
||||
|
||||
ap_decode_end(&(obj->ap_decode_obj), FALSE); /* it is a normal clean up cases.*/
|
||||
|
||||
if (obj->binhex_stream)
|
||||
PR_FREEIF(obj->binhex_stream);
|
||||
|
||||
if (obj->in_buff)
|
||||
PR_FREEIF(obj->in_buff);
|
||||
|
||||
PR_FREEIF(obj);
|
||||
}
|
||||
|
||||
PRIVATE void
|
||||
net_AppleDouble_Decode_Abort (
|
||||
void *stream, int status)
|
||||
{
|
||||
AppleDoubleDecodeObject *obj = (AppleDoubleDecodeObject *)stream;
|
||||
|
||||
ap_decode_end(&(obj->ap_decode_obj), TRUE); /* it is an abort. */
|
||||
|
||||
if (obj->binhex_stream)
|
||||
PR_FREEIF(obj->binhex_stream);
|
||||
|
||||
if (obj->in_buff)
|
||||
PR_FREEIF(obj->in_buff);
|
||||
|
||||
PR_FREEIF(obj);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** fe_MakeAppleDoubleDecodeStream_1
|
||||
** ---------------------------------
|
||||
**
|
||||
** Create the apple double decode stream.
|
||||
**
|
||||
** In the Mac OS, it will create a stream to decode to an apple file;
|
||||
**
|
||||
** In other OS, the stream will decode apple double object,
|
||||
** then encode it in binhex format, and save to the file.
|
||||
*/
|
||||
#ifndef RICHIE_XP_MAC
|
||||
static void
|
||||
simple_copy(MWContext* context, char* saveName, void* closure)
|
||||
{
|
||||
/* just copy the filename to the closure, so the caller can get it. */
|
||||
PL_strcpy(closure, saveName);
|
||||
}
|
||||
#endif
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
fe_MakeAppleDoubleDecodeStream_1 (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
#ifdef RICHIE_XP_MAC
|
||||
return fe_MakeAppleDoubleDecodeStream(format_out,
|
||||
data_obj,
|
||||
URL_s,
|
||||
window_id,
|
||||
false,
|
||||
NULL);
|
||||
#else
|
||||
|
||||
#if 0 /* just a test in the mac OS */
|
||||
NET_StreamClass *p;
|
||||
char* url;
|
||||
StandardFileReply reply;
|
||||
|
||||
StandardPutFile("\pSave binhex encoded file as:", "\pUntitled", &reply);
|
||||
if (!reply.sfGood)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
url = my_PathnameFromFSSpec(&(reply.sfFile));
|
||||
|
||||
p = fe_MakeAppleDoubleDecodeStream(format_out,
|
||||
data_obj,
|
||||
URL_s,
|
||||
window_id,
|
||||
true,
|
||||
url+7);
|
||||
PR_FREEIF(url);
|
||||
return (p);
|
||||
|
||||
#else /* for the none mac-os to get a file name */
|
||||
|
||||
NET_StreamClass *p;
|
||||
char* filename;
|
||||
|
||||
filename = PR_CALLOC(1024);
|
||||
if (filename == NULL)
|
||||
return NULL;
|
||||
|
||||
/***** RICHIE - CONVERT THIS
|
||||
if (FE_PromptForFileName(window_id,
|
||||
RICHIE_XP_GetString(MK_MSG_SAVE_ATTACH_AS),
|
||||
0,
|
||||
FALSE,
|
||||
FALSE,
|
||||
simple_copy,
|
||||
filename) == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
***/
|
||||
|
||||
p = fe_MakeAppleDoubleDecodeStream(format_out,
|
||||
data_obj,
|
||||
URL_s,
|
||||
window_id,
|
||||
TRUE,
|
||||
filename);
|
||||
PR_FREEIF(filename);
|
||||
return (p);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
fe_MakeAppleDoubleDecodeStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id,
|
||||
PRBool write_as_binhex,
|
||||
char *dst_filename)
|
||||
{
|
||||
AppleDoubleDecodeObject* obj;
|
||||
NET_StreamClass* stream;
|
||||
|
||||
TRACEMSG(("Setting up apple double decode stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
stream = new (NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
obj = new (AppleDoubleDecodeObject);
|
||||
if (obj == NULL)
|
||||
{
|
||||
PR_FREEIF(stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
stream->name = "AppleDouble Decode";
|
||||
stream->complete = (MKStreamCompleteFunc) net_AppleDouble_Decode_Complete;
|
||||
stream->abort = (MKStreamAbortFunc) net_AppleDouble_Decode_Abort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_AppleDouble_Decode_Write;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_AppleDouble_Decode_Ready;
|
||||
stream->data_object = obj;
|
||||
stream->window_id = window_id;
|
||||
|
||||
/*
|
||||
** setup all the need information on the apple double encoder.
|
||||
*/
|
||||
obj->in_buff = (char *)PR_CALLOC(1024);
|
||||
if (obj->in_buff == NULL)
|
||||
{
|
||||
PR_FREEIF(obj);
|
||||
PR_FREEIF(stream);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
obj->bytes_in_buff = 0;
|
||||
|
||||
if (write_as_binhex)
|
||||
{
|
||||
obj->binhex_stream =
|
||||
fe_MakeBinHexEncodeStream(format_out,
|
||||
data_obj,
|
||||
URL_s,
|
||||
window_id,
|
||||
dst_filename);
|
||||
if (obj->binhex_stream == NULL)
|
||||
{
|
||||
PR_FREEIF(obj);
|
||||
PR_FREEIF(stream);
|
||||
PR_FREEIF(obj->in_buff);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ap_decode_init(&(obj->ap_decode_obj),
|
||||
FALSE,
|
||||
TRUE,
|
||||
obj->binhex_stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->binhex_stream = NULL;
|
||||
ap_decode_init(&(obj->ap_decode_obj),
|
||||
FALSE,
|
||||
FALSE,
|
||||
window_id);
|
||||
/*
|
||||
* jt 8/8/97 -- I think this should be set to true. But'
|
||||
* let's not touch it for now.
|
||||
*
|
||||
* obj->ap_decode_obj.is_binary = TRUE;
|
||||
*/
|
||||
}
|
||||
|
||||
if (dst_filename)
|
||||
{
|
||||
RICHIE_XP_STRNCPY_SAFE(obj->ap_decode_obj.fname, dst_filename,
|
||||
sizeof(obj->ap_decode_obj.fname));
|
||||
}
|
||||
#ifdef RICHIE_XP_MAC
|
||||
obj->ap_decode_obj.mSpec = (FSSpec*)( URL_s->fe_data );
|
||||
#endif
|
||||
TRACEMSG(("Returning stream from NET_AppleDoubleDecode\n"));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
/*
|
||||
** fe_MakeAppleSingleDecodeStream_1
|
||||
** --------------------------------
|
||||
**
|
||||
** Create the apple single decode stream.
|
||||
**
|
||||
** In the Mac OS, it will create a stream to decode object to an apple file;
|
||||
**
|
||||
** In other OS, the stream will decode apple single object,
|
||||
** then encode context in binhex format, and save to the file.
|
||||
*/
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
fe_MakeAppleSingleDecodeStream_1 (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
#ifdef RICHIE_XP_MAC
|
||||
return fe_MakeAppleSingleDecodeStream(format_out,
|
||||
data_obj,
|
||||
URL_s,
|
||||
window_id,
|
||||
FALSE,
|
||||
NULL);
|
||||
#else
|
||||
|
||||
#if 0 /* just a test in the mac OS */
|
||||
NET_StreamClass *p;
|
||||
char* url;
|
||||
StandardFileReply reply;
|
||||
|
||||
StandardPutFile("\pSave binhex encoded file as:", "\pUntitled", &reply);
|
||||
if (!reply.sfGood)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
url = my_PathnameFromFSSpec(&(reply.sfFile));
|
||||
|
||||
p = fe_MakeAppleSingleDecodeStream(format_out,
|
||||
data_obj,
|
||||
URL_s,
|
||||
window_id,
|
||||
true,
|
||||
url+7);
|
||||
PR_FREEIF(url);
|
||||
return (p);
|
||||
|
||||
#else /* for the none mac-os to get a file name */
|
||||
|
||||
NET_StreamClass *p;
|
||||
char* filename;
|
||||
char* defaultPath = 0;
|
||||
|
||||
defaultPath = URL_s->content_name;
|
||||
|
||||
#ifdef RICHIE_XP_WIN16
|
||||
if (RICHIE_XP_FileNameContainsBadChars(defaultPath))
|
||||
defaultPath = 0;
|
||||
#endif
|
||||
|
||||
filename = PR_CALLOC(1024);
|
||||
if (filename == NULL)
|
||||
return NULL;
|
||||
|
||||
/***** RICHIE - CONVERT THIS
|
||||
if (FE_PromptForFileName(window_id,
|
||||
RICHIE_XP_GetString(MK_MSG_SAVE_ATTACH_AS),
|
||||
defaultPath,
|
||||
FALSE,
|
||||
FALSE,
|
||||
simple_copy,
|
||||
filename) == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
*********/
|
||||
|
||||
p = fe_MakeAppleSingleDecodeStream(format_out,
|
||||
data_obj,
|
||||
URL_s,
|
||||
window_id,
|
||||
FALSE,
|
||||
filename);
|
||||
PR_FREEIF(filename);
|
||||
return (p);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** Create the Apple Doube Decode stream.
|
||||
**
|
||||
*/
|
||||
PUBLIC NET_StreamClass *
|
||||
fe_MakeAppleSingleDecodeStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id,
|
||||
PRBool write_as_binhex,
|
||||
char *dst_filename)
|
||||
{
|
||||
AppleDoubleDecodeObject* obj;
|
||||
NET_StreamClass* stream;
|
||||
int encoding = kEncodeNone; /* default is that we don't know the encoding */
|
||||
|
||||
TRACEMSG(("Setting up apple single decode stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
stream = RICHIE_XP_NEW(NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
obj = RICHIE_XP_NEW(AppleDoubleDecodeObject);
|
||||
if (obj == NULL)
|
||||
{
|
||||
PR_FREEIF(stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
stream->name = "AppleSingle Decode";
|
||||
stream->complete = (MKStreamCompleteFunc) net_AppleDouble_Decode_Complete;
|
||||
stream->abort = (MKStreamAbortFunc) net_AppleDouble_Decode_Abort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_AppleDouble_Decode_Write;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_AppleDouble_Decode_Ready;
|
||||
stream->data_object = obj;
|
||||
stream->window_id = window_id;
|
||||
|
||||
/*
|
||||
** setup all the need information on the apple double encoder.
|
||||
*/
|
||||
obj->in_buff = (char *)PR_CALLOC(1024);
|
||||
if (obj->in_buff == NULL)
|
||||
{
|
||||
PR_FREEIF(obj);
|
||||
PR_FREEIF(stream);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
obj->bytes_in_buff = 0;
|
||||
|
||||
if (write_as_binhex)
|
||||
{
|
||||
obj->binhex_stream =
|
||||
fe_MakeBinHexEncodeStream(format_out,
|
||||
data_obj,
|
||||
URL_s,
|
||||
window_id,
|
||||
dst_filename);
|
||||
if (obj->binhex_stream == NULL)
|
||||
{
|
||||
PR_FREEIF(obj);
|
||||
PR_FREEIF(stream);
|
||||
PR_FREEIF(obj->in_buff);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ap_decode_init(&(obj->ap_decode_obj),
|
||||
TRUE,
|
||||
TRUE,
|
||||
obj->binhex_stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->binhex_stream = NULL;
|
||||
ap_decode_init(&(obj->ap_decode_obj),
|
||||
TRUE,
|
||||
FALSE,
|
||||
window_id);
|
||||
#ifndef RICHIE_XP_MAC
|
||||
obj->ap_decode_obj.is_binary = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (dst_filename)
|
||||
{
|
||||
RICHIE_XP_STRNCPY_SAFE(obj->ap_decode_obj.fname, dst_filename,
|
||||
sizeof(obj->ap_decode_obj.fname));
|
||||
}
|
||||
/* If we are of a broken content-type, impose its encoding. */
|
||||
if (URL_s->content_type
|
||||
&& !RICHIE_XP_STRNCASECMP(URL_s->content_type, "x-uuencode-apple-single", 23))
|
||||
obj->ap_decode_obj.encoding = kEncodeUU;
|
||||
else
|
||||
obj->ap_decode_obj.encoding = kEncodeNone;
|
||||
|
||||
TRACEMSG(("Returning stream from NET_AppleSingleDecode\n"));
|
||||
|
||||
return stream;
|
||||
}
|
@ -1,376 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsID.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nscore.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsMsgAppleDouble.h"
|
||||
#include "nsMsgAppleCodes.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsMsgCompUtils.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
#pragma warn_unusedarg off
|
||||
#include "m_cvstrm.h"
|
||||
|
||||
#pragma cplusplus on
|
||||
|
||||
void
|
||||
DecodingDone( appledouble_decode_object* p_ap_decode_obj )
|
||||
{
|
||||
FSSpec fspec;
|
||||
|
||||
fspec.vRefNum = p_ap_decode_obj->vRefNum;
|
||||
fspec.parID = p_ap_decode_obj->dirId;
|
||||
fspec.name[0] = nsCRT::strlen(p_ap_decode_obj->fname);
|
||||
strcpy((char*)fspec.name+1, p_ap_decode_obj->fname);
|
||||
CMimeMapper * mapper = CPrefs::sMimeTypes.FindMimeType(fspec);
|
||||
if( mapper && (mapper->GetLoadAction() == CMimeMapper::Launch ) )
|
||||
{
|
||||
LFileBufferStream file( fspec );
|
||||
LaunchFile( &file );
|
||||
}
|
||||
}
|
||||
|
||||
#pragma cplusplus reset
|
||||
|
||||
#endif /* the ifdef of XP_MAC */
|
||||
|
||||
|
||||
/*
|
||||
** The initial of the apple double decoder.
|
||||
**
|
||||
** Set up the next output stream based on the input.
|
||||
*/
|
||||
int ap_decode_init(
|
||||
appledouble_decode_object* p_ap_decode_obj,
|
||||
PRBool is_apple_single,
|
||||
PRBool write_as_binhex,
|
||||
void *closure)
|
||||
{
|
||||
memset(p_ap_decode_obj, 0, sizeof(appledouble_decode_object));
|
||||
|
||||
/* presume first buff starts a line */
|
||||
p_ap_decode_obj->uu_starts_line = TRUE;
|
||||
|
||||
if (write_as_binhex)
|
||||
{
|
||||
p_ap_decode_obj->write_as_binhex = TRUE;
|
||||
p_ap_decode_obj->binhex_stream = (NET_StreamClass*)closure;
|
||||
p_ap_decode_obj->data_size = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_ap_decode_obj->write_as_binhex = FALSE;
|
||||
p_ap_decode_obj->binhex_stream = NULL;
|
||||
|
||||
p_ap_decode_obj->context = (MWContext*)closure;
|
||||
}
|
||||
|
||||
p_ap_decode_obj->is_apple_single = is_apple_single;
|
||||
|
||||
if (is_apple_single)
|
||||
{
|
||||
p_ap_decode_obj->encoding = kEncodeNone;
|
||||
}
|
||||
|
||||
return NOERR;
|
||||
}
|
||||
|
||||
static int ap_decode_state_machine(appledouble_decode_object* p_ap_decode_obj);
|
||||
/*
|
||||
* process the buffer
|
||||
*/
|
||||
int ap_decode_next(
|
||||
appledouble_decode_object* p_ap_decode_obj,
|
||||
char *in_buff,
|
||||
PRInt32 buff_size)
|
||||
{
|
||||
/*
|
||||
** install the buff to the decoder.
|
||||
*/
|
||||
p_ap_decode_obj->inbuff = in_buff;
|
||||
p_ap_decode_obj->s_inbuff = buff_size;
|
||||
p_ap_decode_obj->pos_inbuff = 0;
|
||||
|
||||
/*
|
||||
** run off the decode state machine
|
||||
*/
|
||||
return ap_decode_state_machine(p_ap_decode_obj);
|
||||
}
|
||||
|
||||
PRIVATE int ap_decode_state_machine(
|
||||
appledouble_decode_object* p_ap_decode_obj)
|
||||
{
|
||||
int status = NOERR;
|
||||
PRInt32 size;
|
||||
|
||||
switch (p_ap_decode_obj->state)
|
||||
{
|
||||
case kInit:
|
||||
/*
|
||||
** Make sure that there are stuff in the buff
|
||||
** before we can parse the file head .
|
||||
*/
|
||||
if (p_ap_decode_obj->s_inbuff <=1 )
|
||||
return NOERR;
|
||||
|
||||
if (p_ap_decode_obj->is_apple_single)
|
||||
{
|
||||
p_ap_decode_obj->state = kBeginHeaderPortion;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ap_seek_part_start(p_ap_decode_obj);
|
||||
if (status != errDone)
|
||||
return status;
|
||||
|
||||
p_ap_decode_obj->state = kBeginParseHeader;
|
||||
}
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
break;
|
||||
|
||||
case kBeginSeekBoundary:
|
||||
p_ap_decode_obj->state = kSeekingBoundary;
|
||||
status = ap_seek_to_boundary(p_ap_decode_obj, TRUE);
|
||||
if (status == errDone)
|
||||
{
|
||||
p_ap_decode_obj->state = kBeginParseHeader;
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
}
|
||||
break;
|
||||
|
||||
case kSeekingBoundary:
|
||||
status = ap_seek_to_boundary(p_ap_decode_obj, FALSE);
|
||||
if (status == errDone)
|
||||
{
|
||||
p_ap_decode_obj->state = kBeginParseHeader;
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
}
|
||||
break;
|
||||
|
||||
case kBeginParseHeader:
|
||||
p_ap_decode_obj->state = kParsingHeader;
|
||||
status = ap_parse_header(p_ap_decode_obj, TRUE);
|
||||
if (status == errDone)
|
||||
{
|
||||
if (p_ap_decode_obj->which_part == kDataPortion)
|
||||
p_ap_decode_obj->state = kBeginDataPortion;
|
||||
else if (p_ap_decode_obj->which_part == kHeaderPortion)
|
||||
p_ap_decode_obj->state = kBeginHeaderPortion;
|
||||
else
|
||||
p_ap_decode_obj->state = kFinishing;
|
||||
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
}
|
||||
break;
|
||||
|
||||
case kParsingHeader:
|
||||
status = ap_parse_header(p_ap_decode_obj, FALSE);
|
||||
if (status == errDone)
|
||||
{
|
||||
if (p_ap_decode_obj->which_part == kDataPortion)
|
||||
p_ap_decode_obj->state = kBeginDataPortion;
|
||||
else if (p_ap_decode_obj->which_part == kHeaderPortion)
|
||||
p_ap_decode_obj->state = kBeginHeaderPortion;
|
||||
else
|
||||
p_ap_decode_obj->state = kFinishing;
|
||||
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case kBeginHeaderPortion:
|
||||
p_ap_decode_obj->state = kProcessingHeaderPortion;
|
||||
status = ap_decode_process_header(p_ap_decode_obj, TRUE);
|
||||
if (status == errDone)
|
||||
{
|
||||
if (p_ap_decode_obj->is_apple_single)
|
||||
p_ap_decode_obj->state = kBeginDataPortion;
|
||||
else
|
||||
p_ap_decode_obj->state = kBeginSeekBoundary;
|
||||
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
}
|
||||
break;
|
||||
case kProcessingHeaderPortion:
|
||||
status = ap_decode_process_header(p_ap_decode_obj, FALSE);
|
||||
if (status == errDone)
|
||||
{
|
||||
if (p_ap_decode_obj->is_apple_single)
|
||||
p_ap_decode_obj->state = kBeginDataPortion;
|
||||
else
|
||||
p_ap_decode_obj->state = kBeginSeekBoundary;
|
||||
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
}
|
||||
break;
|
||||
|
||||
case kBeginDataPortion:
|
||||
p_ap_decode_obj->state = kProcessingDataPortion;
|
||||
status = ap_decode_process_data(p_ap_decode_obj, TRUE);
|
||||
if (status == errDone)
|
||||
{
|
||||
if (p_ap_decode_obj->is_apple_single)
|
||||
p_ap_decode_obj->state = kFinishing;
|
||||
else
|
||||
p_ap_decode_obj->state = kBeginSeekBoundary;
|
||||
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
}
|
||||
break;
|
||||
|
||||
case kProcessingDataPortion:
|
||||
status = ap_decode_process_data(p_ap_decode_obj, FALSE);
|
||||
if (status == errDone)
|
||||
{
|
||||
if (p_ap_decode_obj->is_apple_single)
|
||||
p_ap_decode_obj->state = kFinishing;
|
||||
else
|
||||
p_ap_decode_obj->state = kBeginSeekBoundary;
|
||||
|
||||
status = ap_decode_state_machine(p_ap_decode_obj);
|
||||
}
|
||||
break;
|
||||
|
||||
case kFinishing:
|
||||
if (p_ap_decode_obj->write_as_binhex)
|
||||
{
|
||||
if (p_ap_decode_obj->tmpfd)
|
||||
{
|
||||
/*
|
||||
** It is time to append the data fork to bin hex encoder.
|
||||
**
|
||||
** The reason behind this dirt work is resource fork is the last
|
||||
** piece in the binhex, while it is the first piece in apple double.
|
||||
*/
|
||||
p_ap_decode_obj->tmpFileStream->seek(PR_SEEK_SET, 0);
|
||||
|
||||
while (p_ap_decode_obj->data_size > 0)
|
||||
{
|
||||
char buff[1024];
|
||||
|
||||
size = PR_MIN(1024, p_ap_decode_obj->data_size);
|
||||
p_ap_decode_obj->tmpFileStream->read(buff, size);
|
||||
status = (*p_ap_decode_obj->binhex_stream->put_block)
|
||||
(p_ap_decode_obj->binhex_stream->data_object,
|
||||
buff,
|
||||
size);
|
||||
|
||||
p_ap_decode_obj->data_size -= size;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_ap_decode_obj->data_size <= 0)
|
||||
{
|
||||
/* CALL put_block with size == 0 to close a part. */
|
||||
status = (*p_ap_decode_obj->binhex_stream->put_block)
|
||||
(p_ap_decode_obj->binhex_stream->data_object,
|
||||
NULL,
|
||||
0);
|
||||
if (status != NOERR)
|
||||
break;
|
||||
|
||||
/* and now we are really done. */
|
||||
status = errDone;
|
||||
}
|
||||
else
|
||||
status = NOERR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (status == errEOB) ? NOERR : status;
|
||||
}
|
||||
|
||||
int ap_decode_end(
|
||||
appledouble_decode_object* p_ap_decode_obj,
|
||||
PRBool is_aborting)
|
||||
{
|
||||
/*
|
||||
** clear up the apple doubler object.
|
||||
*/
|
||||
if (p_ap_decode_obj == NULL)
|
||||
return NOERR;
|
||||
|
||||
PR_FREEIF(p_ap_decode_obj->boundary0);
|
||||
|
||||
#ifdef XP_MAC
|
||||
if (p_ap_decode_obj->fileId)
|
||||
FSClose(p_ap_decode_obj->fileId);
|
||||
if( p_ap_decode_obj->vRefNum )
|
||||
FlushVol(nil, p_ap_decode_obj->vRefNum );
|
||||
#endif
|
||||
|
||||
if (p_ap_decode_obj->write_as_binhex)
|
||||
{
|
||||
/*
|
||||
** make sure close the binhex stream too.
|
||||
*/
|
||||
if (is_aborting)
|
||||
{
|
||||
(*p_ap_decode_obj->binhex_stream->abort)
|
||||
(p_ap_decode_obj->binhex_stream->data_object, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*p_ap_decode_obj->binhex_stream->complete)
|
||||
(p_ap_decode_obj->binhex_stream->data_object);
|
||||
}
|
||||
|
||||
if (p_ap_decode_obj->tmpFileStream)
|
||||
p_ap_decode_obj->tmpFileStream->close();
|
||||
|
||||
if (p_ap_decode_obj->tmpFileSpec)
|
||||
{
|
||||
p_ap_decode_obj->tmpFileSpec->Delete(PR_FALSE); /* remove tmp file if we used it */
|
||||
delete p_ap_decode_obj->tmpFileSpec;
|
||||
}
|
||||
}
|
||||
else if (p_ap_decode_obj->fileStream)
|
||||
{
|
||||
p_ap_decode_obj->fileStream->close();
|
||||
}
|
||||
#ifdef XP_MAC
|
||||
if( !is_aborting )
|
||||
DecodingDone( p_ap_decode_obj);
|
||||
#endif
|
||||
return NOERR;
|
||||
|
||||
}
|
@ -1292,44 +1292,6 @@ PRInt32 nsSmtpProtocol::SendDataResponse()
|
||||
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
return(NS_ERROR_SENDING_DATA_COMMAND);
|
||||
}
|
||||
#ifdef UNREADY_CODE
|
||||
#ifdef XP_UNIX
|
||||
{
|
||||
const char * FE_UsersRealMailAddress(void); /* definition */
|
||||
const char *real_name;
|
||||
char *s = 0;
|
||||
PRBool suppress_sender_header = PR_FALSE;
|
||||
|
||||
PREF_GetBoolPref ("mail.suppress_sender_header", &suppress_sender_header);
|
||||
if (!suppress_sender_header)
|
||||
{
|
||||
real_name = FE_UsersRealMailAddress();
|
||||
s = (real_name ? MSG_MakeFullAddress (NULL, real_name) : 0);
|
||||
if (real_name && !s)
|
||||
{
|
||||
m_urlErrorState = NS_ERROR_COULD_NOT_GET_UID;
|
||||
return(NS_ERROR_COULD_NOT_GET_UID);
|
||||
}
|
||||
if(real_name)
|
||||
{
|
||||
char buffer[512];
|
||||
PR_snprintf(buffer, sizeof(buffer), "Sender: %.256s" CRLF, real_name);
|
||||
NS_MsgSACat(command, buffer);
|
||||
if(!command)
|
||||
{
|
||||
m_urlErrorState = NS_ERROR_OUT_OF_MEMORY;
|
||||
return(NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
status = (int) NET_BlockingWrite(CE_SOCK, command, PL_strlen(command));
|
||||
if(status < 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* XP_UNIX */
|
||||
#endif /* UNREADY_CODE */
|
||||
|
||||
PR_FREEIF(command);
|
||||
|
||||
@ -1338,19 +1300,6 @@ PRInt32 nsSmtpProtocol::SendDataResponse()
|
||||
|
||||
UpdateStatus(SMTP_DELIV_MAIL);
|
||||
|
||||
#ifdef UNREADY_CODE
|
||||
/* get the size of the message */
|
||||
if(CE_URL_S->post_data_is_file)
|
||||
{
|
||||
XP_StatStruct stat_entry;
|
||||
|
||||
if(-1 != XP_Stat(CE_URL_S->post_data,
|
||||
&stat_entry,
|
||||
xpFileToPost))
|
||||
m_totalMessageSize = stat_entry.st_size;
|
||||
}
|
||||
else
|
||||
#endif /* UNREADY_CODE */
|
||||
{
|
||||
// m_runningURL->GetBodySize(&m_totalMessageSize);
|
||||
}
|
||||
@ -1406,21 +1355,6 @@ PRInt32 nsSmtpProtocol::SendPostData()
|
||||
"message sent; waiting for reply" status; FE_GraphProgress gets in
|
||||
the way of that. See bug #23414. */
|
||||
|
||||
#ifdef UNREADY_CODE
|
||||
unsigned long curtime;
|
||||
curtime = XP_TIME();
|
||||
if (curtime != m_LastTime) {
|
||||
FE_Progress(CE_WINDOW_ID, XP_ProgressText(m_totalMessageSize,
|
||||
m_totalAmountWritten,
|
||||
0, 0));
|
||||
m_LastTime = curtime;
|
||||
}
|
||||
|
||||
if(m_totalMessageSize)
|
||||
FE_SetProgressBarPercent(CE_WINDOW_ID,
|
||||
m_totalAmountWritten*100/m_totalMessageSize);
|
||||
#endif /* UNREADY_CODE */
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
@ -1518,13 +1518,8 @@ PRInt32 nsNNTPProtocol::NewsResponse(nsIInputStream * inputStream, PRUint32 leng
|
||||
/* almost correct */
|
||||
if(status > 1)
|
||||
{
|
||||
#ifdef UNREADY_CODE
|
||||
ce->bytes_received += status;
|
||||
FE_GraphProgress(ce->window_id, ce->URL_s, ce->bytes_received, status, ce->URL_s->content_length);
|
||||
#else
|
||||
mBytesReceived += status;
|
||||
mBytesReceivedSinceLastStatusUpdate += status;
|
||||
#endif
|
||||
}
|
||||
|
||||
m_previousResponseCode = m_responseCode;
|
||||
@ -1583,9 +1578,6 @@ PRInt32 nsNNTPProtocol::LoginResponse()
|
||||
AlertError(MK_NNTP_ERROR_MESSAGE, m_responseText);
|
||||
|
||||
m_nextState = NNTP_ERROR;
|
||||
#ifdef UNREADY_CODE
|
||||
cd->control_con->prev_cache = PR_FALSE; /* to keep if from reconnecting */
|
||||
#endif
|
||||
return MK_BAD_NNTP_CONNECTION;
|
||||
}
|
||||
|
||||
@ -2032,15 +2024,6 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef UNREADY_CODE
|
||||
#ifdef BUG_21013
|
||||
if(!FE_Confirm(ce->window_id, XP_GetString(XP_CONFIRM_SAVE_NEWSGROUPS)))
|
||||
{
|
||||
m_nextState = NEWS_ERROR;
|
||||
return(MK_INTERRUPTED);
|
||||
}
|
||||
#endif /* BUG_21013 */
|
||||
#endif
|
||||
PRBool xactive=PR_FALSE;
|
||||
rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
|
||||
if (NS_SUCCEEDED(rv) && xactive)
|
||||
@ -2148,11 +2131,6 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
|
||||
}
|
||||
}
|
||||
m_nextState = NNTP_RESPONSE;
|
||||
#ifdef UNREADY_CODE
|
||||
if (PL_strstr(ce->URL_s->address, "PROFILE NEW"))
|
||||
m_nextStateAfterResponse = NNTP_PROFILE_ADD_RESPONSE;
|
||||
else
|
||||
#endif
|
||||
m_nextStateAfterResponse = NNTP_PROFILE_DELETE_RESPONSE;
|
||||
}
|
||||
else if (m_typeWanted == IDS_WANTED)
|
||||
@ -2327,15 +2305,8 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
|
||||
|
||||
/* start the graph progress indicator
|
||||
*/
|
||||
#ifdef UNREADY_CODE
|
||||
FE_GraphProgressInit(ce->window_id, ce->URL_s, ce->URL_s->content_length);
|
||||
#else
|
||||
NNTP_LOG_NOTE("start the graph progress indicator");
|
||||
#endif
|
||||
SetFlag(NNTP_DESTROY_PROGRESS_GRAPH);
|
||||
#ifdef UNREADY_CODE
|
||||
m_originalContentLength = ce->URL_s->content_length;
|
||||
#endif
|
||||
return(status);
|
||||
}
|
||||
|
||||
@ -2421,41 +2392,11 @@ PRInt32 nsNNTPProtocol::BeginArticle()
|
||||
|
||||
/* Set up the HTML stream
|
||||
*/
|
||||
#ifdef UNREADY_CODE
|
||||
ce->URL_s->content_type = nsCRT::strdup (MESSAGE_RFC822);
|
||||
#endif
|
||||
|
||||
#ifdef NO_ARTICLE_CACHEING
|
||||
ce->format_out = CLEAR_CACHE_BIT (ce->format_out);
|
||||
#endif
|
||||
|
||||
if (m_typeWanted == CANCEL_WANTED)
|
||||
{
|
||||
#ifdef UNREADY_CODE
|
||||
NS_ASSERTION(ce->format_out == FO_PRESENT, "format_out != FO_PRESENT");
|
||||
ce->format_out = FO_PRESENT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Only put stuff in the fe_data if this URL is going to get
|
||||
passed to MIME_MessageConverter(), since that's the only
|
||||
thing that knows what to do with this structure. */
|
||||
#ifdef UNREADY_CODE
|
||||
if (CLEAR_CACHE_BIT(ce->format_out) == FO_PRESENT)
|
||||
{
|
||||
status = net_InitializeNewsFeData (ce);
|
||||
if (status < 0)
|
||||
{
|
||||
/* #### what error message? */
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
cd->stream = NET_StreamBuilder(ce->format_out, ce->URL_s, ce->window_id);
|
||||
NS_ASSERTION (cd->stream, "no stream");
|
||||
if (!cd->stream) return -1;
|
||||
#endif
|
||||
|
||||
// if we have a channel listener,
|
||||
// create a pipe to pump the message into...the output will go to whoever
|
||||
// is consuming the message display
|
||||
@ -2930,15 +2871,9 @@ PRInt32 nsNNTPProtocol::BeginNewsgroups()
|
||||
{
|
||||
PRInt32 status = 0;
|
||||
m_nextState = NNTP_NEWGROUPS;
|
||||
#ifdef UNREADY_CODE
|
||||
NET_Progress(ce->window_id, XP_GetString(XP_PROGRESS_RECEIVE_NEWSGROUP));
|
||||
|
||||
ce->bytes_received = 0;
|
||||
#else
|
||||
mBytesReceived = 0;
|
||||
mBytesReceivedSinceLastStatusUpdate = 0;
|
||||
m_startTime = PR_Now();
|
||||
#endif
|
||||
return(status);
|
||||
}
|
||||
|
||||
@ -3076,10 +3011,7 @@ PRInt32 nsNNTPProtocol::BeginReadNewsList()
|
||||
m_startTime = PR_Now();
|
||||
|
||||
PRInt32 status = 0;
|
||||
#ifdef UNREADY_CODE
|
||||
NET_Progress(ce->window_id, XP_GetString(XP_PROGRESS_RECEIVE_NEWSGROUP));
|
||||
#endif
|
||||
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
@ -3799,34 +3731,6 @@ PRInt32 nsNNTPProtocol::PostDataResponse()
|
||||
if (m_responseCode != MK_NNTP_RESPONSE_POST_OK)
|
||||
{
|
||||
AlertError(MK_NNTP_ERROR_MESSAGE,m_responseText);
|
||||
#ifdef UNREADY_CODE
|
||||
ce->URL_s->error_msg =
|
||||
NET_ExplainErrorDetails(MK_NNTP_ERROR_MESSAGE,
|
||||
m_responseText ? m_responseText : "");
|
||||
if (m_responseCode == MK_NNTP_RESPONSE_POST_FAILED
|
||||
&& MSG_GetPaneType(cd->pane) == MSG_COMPOSITIONPANE
|
||||
&& MSG_IsDuplicatePost(cd->pane) &&
|
||||
MSG_GetCompositionMessageID(cd->pane)) {
|
||||
/* The news server won't let us post. We suspect that we're submitting
|
||||
a duplicate post, and that's why it's failing. So, let's go see
|
||||
if there really is a message out there with the same message-id.
|
||||
If so, we'll just silently pretend everything went well. */
|
||||
PR_snprintf(cd->output_buffer, OUTPUT_BUFFER_SIZE, "STAT %s" CRLF,
|
||||
MSG_GetCompositionMessageID(cd->pane));
|
||||
m_nextState = NNTP_RESPONSE;
|
||||
m_nextStateAfterResponse = NNTP_CHECK_FOR_MESSAGE;
|
||||
NNTP_LOG_WRITE(cd->output_buffer);
|
||||
return (int) NET_BlockingWrite(ce->socket, cd->output_buffer,
|
||||
PL_strlen(cd->output_buffer));
|
||||
}
|
||||
|
||||
MSG_ClearCompositionMessageID(cd->pane); /* So that if the user tries
|
||||
to just post again, we
|
||||
won't immediately decide
|
||||
that this was a duplicate
|
||||
message and ignore the
|
||||
error. */
|
||||
#endif
|
||||
m_nextState = NEWS_ERROR;
|
||||
return(MK_NNTP_ERROR_MESSAGE);
|
||||
}
|
||||
@ -3847,9 +3751,6 @@ PRInt32 nsNNTPProtocol::CheckForArticle()
|
||||
/* The article isn't there, so the failure we had earlier wasn't due to
|
||||
a duplicate message-id. Return the error from that previous
|
||||
posting attempt (which is already in ce->URL_s->error_msg). */
|
||||
#ifdef UNREADY_CODE
|
||||
MSG_ClearCompositionMessageID(cd->pane);
|
||||
#endif
|
||||
return MK_NNTP_ERROR_MESSAGE;
|
||||
}
|
||||
}
|
||||
|
@ -5731,10 +5731,6 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
||||
|
||||
nsCOMPtr<nsIRDFResource> res;
|
||||
|
||||
// #define OLDWAY
|
||||
#ifdef OLDWAY
|
||||
rv = gRDFService->GetResource(nsCAutoString(hrefStr), getter_AddRefs(res));
|
||||
#else
|
||||
// save HREF attribute as URL
|
||||
if (NS_SUCCEEDED(rv = gRDFService->GetAnonymousResource(getter_AddRefs(res))))
|
||||
{
|
||||
@ -5748,7 +5744,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
// set HTML response chunk
|
||||
@ -5849,9 +5845,6 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
||||
|
||||
// look for Name (if it isn't already set)
|
||||
nsCOMPtr<nsIRDFNode> oldNameRes = nsnull;
|
||||
#ifdef OLDWAY
|
||||
mInner->GetTarget(res, kNC_Name, PR_TRUE, getter_AddRefs(oldNameRes));
|
||||
#endif
|
||||
if (!oldNameRes)
|
||||
{
|
||||
if (!nameStr.IsEmpty())
|
||||
@ -6005,9 +5998,6 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
||||
|
||||
// look for Relevance (if it isn't already set)
|
||||
nsCOMPtr<nsIRDFNode> oldRelRes = nsnull;
|
||||
#ifdef OLDWAY
|
||||
mInner->GetTarget(res, kNC_Relevance, PR_TRUE, getter_AddRefs(oldRelRes));
|
||||
#endif
|
||||
if (!oldRelRes)
|
||||
{
|
||||
if (!relItem.IsEmpty())
|
||||
@ -6100,9 +6090,6 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent,
|
||||
|
||||
// set reference to engine this came from (if it isn't already set)
|
||||
nsCOMPtr<nsIRDFNode> oldEngineRes = nsnull;
|
||||
#ifdef OLDWAY
|
||||
mInner->GetTarget(res, kNC_Engine, PR_TRUE, getter_AddRefs(oldEngineRes));
|
||||
#endif
|
||||
if (!oldEngineRes)
|
||||
{
|
||||
if (!engineStr.IsEmpty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user