Compare commits
1 Commits
GIF_CLEANU
...
tags/pre-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af3598ba92 |
File diff suppressed because it is too large
Load Diff
@@ -1,338 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef _GIF_H_
|
||||
#define _GIF_H_
|
||||
|
||||
/* gif2.h
|
||||
The interface for the GIF87/89a decoder.
|
||||
*/
|
||||
// List of possible parsing states
|
||||
typedef enum {
|
||||
gif_gather,
|
||||
gif_init, //1
|
||||
gif_type,
|
||||
gif_version,
|
||||
gif_global_header,
|
||||
gif_global_colormap,
|
||||
gif_image_start, //6
|
||||
gif_image_header,
|
||||
gif_image_colormap,
|
||||
gif_image_body,
|
||||
gif_lzw_start,
|
||||
gif_lzw, //11
|
||||
gif_sub_block,
|
||||
gif_extension,
|
||||
gif_control_extension,
|
||||
gif_consume_block,
|
||||
gif_skip_block,
|
||||
gif_done, //17
|
||||
gif_oom,
|
||||
gif_error,
|
||||
gif_comment_extension,
|
||||
gif_application_extension,
|
||||
gif_netscape_extension_block,
|
||||
gif_consume_netscape_extension,
|
||||
gif_consume_comment,
|
||||
gif_delay,
|
||||
gif_wait_for_buffer_full,
|
||||
gif_stop_animating //added for animation stop
|
||||
} gstate;
|
||||
|
||||
/* "Disposal" method indicates how the image should be handled in the
|
||||
framebuffer before the subsequent image is displayed. */
|
||||
typedef enum
|
||||
{
|
||||
DISPOSE_NOT_SPECIFIED = 0,
|
||||
DISPOSE_KEEP = 1, /* Leave it in the framebuffer */
|
||||
DISPOSE_OVERWRITE_BGCOLOR = 2, /* Overwrite with background color */
|
||||
DISPOSE_OVERWRITE_PREVIOUS = 4 /* Save-under */
|
||||
} gdispose;
|
||||
|
||||
/* A RGB triplet representing a single pixel in the image's colormap
|
||||
(if present.) */
|
||||
typedef struct _GIF_RGB
|
||||
{
|
||||
PRUint8 red, green, blue, pad; /* Windows requires the fourth byte &
|
||||
many compilers pad it anyway. */
|
||||
|
||||
/* XXX: hist_count appears to be unused */
|
||||
//PRUint16 hist_count; /* Histogram frequency count. */
|
||||
} GIF_RGB;
|
||||
|
||||
/* Colormap information. */
|
||||
typedef struct _GIF_ColorMap {
|
||||
int32 num_colors; /* Number of colors in the colormap.
|
||||
A negative value can be used to denote a
|
||||
possibly non-unique set. */
|
||||
GIF_RGB *map; /* Colormap colors. */
|
||||
PRUint8 *index; /* NULL, if map is in index order. Otherwise
|
||||
specifies the indices of the map entries. */
|
||||
void *table; /* Lookup table for this colormap. Private to
|
||||
the Image Library. */
|
||||
} GIF_ColorMap;
|
||||
|
||||
/* An indexed RGB triplet. */
|
||||
typedef struct _GIF_IRGB {
|
||||
PRUint8 index;
|
||||
PRUint8 red, green, blue;
|
||||
} GIF_IRGB;
|
||||
|
||||
/* A GIF decoder's state */
|
||||
typedef struct gif_struct {
|
||||
void* clientptr;
|
||||
/* Callbacks for this decoder instance*/
|
||||
int (PR_CALLBACK *GIFCallback_NewPixmap)();
|
||||
int (PR_CALLBACK *GIFCallback_BeginGIF)(
|
||||
void* aClientData,
|
||||
PRUint32 aLogicalScreenWidth,
|
||||
PRUint32 aLogicalScreenHeight,
|
||||
PRUint8 aLogicalScreenBackgroundRGBIndex);
|
||||
|
||||
int (PR_CALLBACK* GIFCallback_EndGIF)(
|
||||
void* aClientData,
|
||||
int aAnimationLoopCount);
|
||||
|
||||
int (PR_CALLBACK* GIFCallback_BeginImageFrame)(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber, /* Frame number, 1-n */
|
||||
PRUint32 aFrameXOffset, /* X offset in logical screen */
|
||||
PRUint32 aFrameYOffset, /* Y offset in logical screen */
|
||||
PRUint32 aFrameWidth,
|
||||
PRUint32 aFrameHeight,
|
||||
GIF_RGB* aTransparencyChromaKey);
|
||||
int (PR_CALLBACK* GIFCallback_EndImageFrame)(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber,
|
||||
PRUint32 aDelayTimeout,
|
||||
PRUint32 aDisposal);
|
||||
int (PR_CALLBACK* GIFCallback_SetupColorspaceConverter)();
|
||||
int (PR_CALLBACK* GIFCallback_ResetPalette)();
|
||||
int (PR_CALLBACK* GIFCallback_InitTransparentPixel)();
|
||||
int (PR_CALLBACK* GIFCallback_DestroyTransparentPixel)();
|
||||
int (PR_CALLBACK* GIFCallback_HaveDecodedRow)(
|
||||
void* aClientData,
|
||||
PRUint8* aRowBufPtr, /* Pointer to single scanline temporary buffer */
|
||||
int aXOffset, /* With respect to GIF logical screen origin */
|
||||
int aLength, /* Length of the row? */
|
||||
int aRow, /* Row number? */
|
||||
int aDuplicateCount, /* Number of times to duplicate the row? */
|
||||
PRUint8 aDrawMode, /* il_draw_mode */
|
||||
int aInterlacePass);
|
||||
int (PR_CALLBACK *GIFCallback_HaveImageAll)(
|
||||
void* aClientData);
|
||||
|
||||
/* Parsing state machine */
|
||||
gstate state; /* Curent decoder master state */
|
||||
PRUint8 *hold; /* Accumulation buffer */
|
||||
int32 hold_size; /* Capacity, in bytes, of accumulation buffer */
|
||||
PRUint8 *gather_head; /* Next byte to read in accumulation buffer */
|
||||
int32 gather_request_size; /* Number of bytes to accumulate */
|
||||
int32 gathered; /* bytes accumulated so far*/
|
||||
gstate post_gather_state; /* State after requested bytes accumulated */
|
||||
int32 requested_buffer_fullness; /* For netscape application extension */
|
||||
|
||||
/* LZW decoder state machine */
|
||||
PRUint8 *stack; /* Base of decoder stack */
|
||||
PRUint8 *stackp; /* Current stack pointer */
|
||||
PRUint16 *prefix;
|
||||
PRUint8 *suffix;
|
||||
int datasize;
|
||||
int codesize;
|
||||
int codemask;
|
||||
int clear_code; /* Codeword used to trigger dictionary reset */
|
||||
int avail; /* Index of next available slot in dictionary */
|
||||
int oldcode;
|
||||
PRUint8 firstchar;
|
||||
int count; /* Remaining # bytes in sub-block */
|
||||
int bits; /* Number of unread bits in "datum" */
|
||||
int32 datum; /* 32-bit input buffer */
|
||||
|
||||
/* Output state machine */
|
||||
int ipass; /* Interlace pass; Ranges 1-4 if interlaced. */
|
||||
PRUintn rows_remaining; /* Rows remaining to be output */
|
||||
PRUintn irow; /* Current output row, starting at zero */
|
||||
PRUint8 *rowbuf; /* Single scanline temporary buffer */
|
||||
PRUint8 *rowend; /* Pointer to end of rowbuf */
|
||||
PRUint8 *rowp; /* Current output pointer */
|
||||
|
||||
/* Parameters for image frame currently being decoded*/
|
||||
PRUintn x_offset, y_offset; /* With respect to "screen" origin */
|
||||
PRUintn height, width;
|
||||
PRUintn last_x_offset, last_y_offset; /* With respect to "screen" origin */
|
||||
PRUintn last_height, last_width;
|
||||
int interlaced; /* TRUE, if scanlines arrive interlaced order */
|
||||
int tpixel; /* Index of transparent pixel */
|
||||
GIF_IRGB* transparent_pixel;
|
||||
int is_transparent; /* TRUE, if tpixel is valid */
|
||||
int control_extension; /* TRUE, if image control extension present */
|
||||
int is_local_colormap_defined;
|
||||
gdispose disposal_method; /* Restore to background, leave in place, etc.*/
|
||||
gdispose last_disposal_method;
|
||||
GIF_RGB *local_colormap; /* Per-image colormap */
|
||||
int local_colormap_size; /* Size of local colormap array. */
|
||||
PRUint32 delay_time; /* Display time, in milliseconds,
|
||||
for this image in a multi-image GIF */
|
||||
|
||||
/* Global (multi-image) state */
|
||||
int screen_bgcolor; /* Logical screen background color */
|
||||
int version; /* Either 89 for GIF89 or 87 for GIF87 */
|
||||
PRUintn screen_width; /* Logical screen width & height */
|
||||
PRUintn screen_height;
|
||||
GIF_RGB *global_colormap; /* Default colormap if local not supplied */
|
||||
int global_colormap_size; /* Size of global colormap array. */
|
||||
int images_decoded; /* Counts images for multi-part GIFs */
|
||||
int destroy_pending; /* Stream has ended */
|
||||
int progressive_display; /* If TRUE, do Haeberli interlace hack */
|
||||
int loop_count; /* Netscape specific extension block to control
|
||||
the number of animation loops a GIF renders. */
|
||||
} gif_struct;
|
||||
|
||||
|
||||
/* Create a new gif_struct */
|
||||
extern PRBool gif_create(gif_struct **gs);
|
||||
|
||||
/* These are the APIs that the client calls to intialize,
|
||||
push data to, and shut down the GIF decoder. */
|
||||
PRBool GIFInit(
|
||||
gif_struct* gs,
|
||||
|
||||
void* aClientData,
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_NewPixmap)(),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_BeginGIF)(
|
||||
void* aClientData,
|
||||
PRUint32 aLogicalScreenWidth,
|
||||
PRUint32 aLogicalScreenHeight,
|
||||
PRUint8 aBackgroundRGBIndex),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_EndGIF)(
|
||||
void* aClientData,
|
||||
int aAnimationLoopCount),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_BeginImageFrame)(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber, /* Frame number, 1-n */
|
||||
PRUint32 aFrameXOffset, /* X offset in logical screen */
|
||||
PRUint32 aFrameYOffset, /* Y offset in logical screen */
|
||||
PRUint32 aFrameWidth,
|
||||
PRUint32 aFrameHeight,
|
||||
GIF_RGB* aTransparencyChromaKey),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_EndImageFrame)(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber,
|
||||
PRUint32 aDelayTimeout,
|
||||
PRUint32 aDisposal),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_SetupColorspaceConverter)(),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_ResetPalette)(),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_InitTransparentPixel)(),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_DestroyTransparentPixel)(),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_HaveDecodedRow)(
|
||||
void* aClientData,
|
||||
PRUint8* aRowBufPtr, /* Pointer to single scanline temporary buffer */
|
||||
int aXOffset, /* With respect to GIF logical screen origin */
|
||||
int aLength, /* Length of the row? */
|
||||
int aRow, /* Row number? */
|
||||
int aDuplicateCount, /* Number of times to duplicate the row? */
|
||||
PRUint8 aDrawMode, /* il_draw_mode */
|
||||
int aInterlacePass),
|
||||
|
||||
int (*PR_CALLBACK GIFCallback_HaveImageAll)(
|
||||
void* aClientData)
|
||||
);
|
||||
|
||||
extern void gif_destroy(gif_struct* aGIFStruct);
|
||||
|
||||
PRStatus gif_write(gif_struct* aGIFStruct, const PRUint8 * buf, PRUint32 numbytes);
|
||||
|
||||
PRBool gif_write_ready(const gif_struct* aGIFStruct);
|
||||
|
||||
extern void gif_complete(gif_struct** aGIFStruct);
|
||||
extern void gif_delay_time_callback(/* void *closure */);
|
||||
|
||||
|
||||
/* Callback functions that the client must implement and pass in
|
||||
pointers for during the GIFInit call. These will be called back
|
||||
when the decoder has a decoded rows, frame size information, etc.*/
|
||||
|
||||
/* GIFCallback_LogicalScreenSize is called only once to notify the client
|
||||
of the logical screen size, which will be the size of the total image. */
|
||||
typedef int (*PR_CALLBACK BEGINGIF_CALLBACK)(
|
||||
void* aClientData,
|
||||
PRUint32 aLogicalScreenWidth,
|
||||
PRUint32 aLogicalScreenHeight,
|
||||
PRUint8 aLogicalScreenBackgroundRGBIndex);
|
||||
|
||||
typedef int (PR_CALLBACK *GIFCallback_EndGIF)(
|
||||
void* aClientData,
|
||||
int aAnimationLoopCount);
|
||||
|
||||
/* GIFCallback_BeginImageFrame is called at the beginning of each frame of
|
||||
a GIF.*/
|
||||
typedef int (PR_CALLBACK *GIFCallback_BeginImageFrame)(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber, /* Frame number, 1-n */
|
||||
PRUint32 aFrameXOffset, /* X offset in logical screen */
|
||||
PRUint32 aFraqeYOffset, /* Y offset in logical screen */
|
||||
PRUint32 aFrameWidth,
|
||||
PRUint32 aFrameHeight);
|
||||
|
||||
extern int GIFCallback_EndImageFrame(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber,
|
||||
PRUint32 aDelayTimeout,
|
||||
PRUint32 aDisposal); /* Time in milliseconds this frame should be displayed before the next frame.
|
||||
This information appears in a sub control block, so we don't
|
||||
transmit it back to the client until we're done with the frame. */
|
||||
|
||||
/*
|
||||
extern int GIFCallback_SetupColorspaceConverter();
|
||||
extern int GIFCallback_ResetPalette();
|
||||
extern int GIFCallback_InitTransparentPixel();
|
||||
extern int GIFCallback_DestroyTransparentPixel();
|
||||
*/
|
||||
extern int GIFCallback_HaveDecodedRow();
|
||||
extern int GIFCallback_HaveImageAll();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = imggif
|
||||
LIBRARY_NAME = imggif
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsGIFModule2
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
EXTRA_DSO_LIBS = gkgfx
|
||||
endif
|
||||
|
||||
REQUIRES = xpcom \
|
||||
gfx \
|
||||
gfx2 \
|
||||
imglib2 \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = GIF2.cpp nsGIFDecoder2.cpp nsGIFModule.cpp
|
||||
|
||||
EXTRA_DSO_LDOPTS = $(GIF_LIBS) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Stuart Parmenter <pavlov@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
MODULE = imggif
|
||||
REQUIRES = xpcom \
|
||||
gfx \
|
||||
gfx2 \
|
||||
imglib2 \
|
||||
$(NULL)
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
LIBRARY_NAME = imggif
|
||||
MODULE_NAME = nsGIFModule2
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\nsGIFDecoder2.obj \
|
||||
.\$(OBJDIR)\GIF2.obj \
|
||||
.\$(OBJDIR)\nsGIFModule.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS=\
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\gkgfx.lib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,555 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Saari <saari@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsGIFDecoder2.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIImage.h"
|
||||
#include "nsMemory.h"
|
||||
|
||||
#include "imgIContainerObserver.h"
|
||||
|
||||
#include "imgILoad.h"
|
||||
|
||||
#include "nsRect.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// GIF Decoder Implementation
|
||||
// This is an adaptor between GIF2 and imgIDecoder
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGIFDecoder2, imgIDecoder);
|
||||
|
||||
nsGIFDecoder2::nsGIFDecoder2()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mImageFrame = nsnull;
|
||||
|
||||
mGIFStruct = nsnull;
|
||||
|
||||
mAlphaLine = nsnull;
|
||||
mRGBLine = nsnull;
|
||||
mBackgroundRGBIndex = 0;
|
||||
|
||||
mCurrentRow = -1;
|
||||
mLastFlushedRow = -1;
|
||||
|
||||
mCurrentPass = 0;
|
||||
mLastFlushedPass = 0;
|
||||
}
|
||||
|
||||
nsGIFDecoder2::~nsGIFDecoder2(void)
|
||||
{
|
||||
if (mAlphaLine)
|
||||
nsMemory::Free(mAlphaLine);
|
||||
|
||||
if (mRGBLine)
|
||||
nsMemory::Free(mRGBLine);
|
||||
|
||||
if (mGIFStruct) {
|
||||
gif_destroy(mGIFStruct);
|
||||
mGIFStruct = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/** imgIDecoder methods **/
|
||||
//******************************************************************************
|
||||
|
||||
//******************************************************************************
|
||||
/* void init (in imgILoad aLoad); */
|
||||
NS_IMETHODIMP nsGIFDecoder2::Init(imgILoad *aLoad)
|
||||
{
|
||||
mObserver = do_QueryInterface(aLoad);
|
||||
|
||||
mImageContainer = do_CreateInstance("@mozilla.org/image/container;1");
|
||||
aLoad->SetImage(mImageContainer);
|
||||
|
||||
/* do gif init stuff */
|
||||
/* Always decode to 24 bit pixdepth */
|
||||
|
||||
PRBool created = gif_create(&mGIFStruct);
|
||||
|
||||
NS_ASSERTION(created, "gif_create failed");
|
||||
|
||||
// Call GIF decoder init routine
|
||||
GIFInit(
|
||||
mGIFStruct,
|
||||
this,
|
||||
NewPixmap,
|
||||
BeginGIF,
|
||||
EndGIF,
|
||||
BeginImageFrame,
|
||||
EndImageFrame,
|
||||
SetupColorspaceConverter,
|
||||
ResetPalette,
|
||||
InitTransparentPixel,
|
||||
DestroyTransparentPixel,
|
||||
HaveDecodedRow,
|
||||
HaveImageAll);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
/** nsIOutputStream methods **/
|
||||
//******************************************************************************
|
||||
|
||||
//******************************************************************************
|
||||
/* void close (); */
|
||||
NS_IMETHODIMP nsGIFDecoder2::Close()
|
||||
{
|
||||
if (mGIFStruct) {
|
||||
gif_destroy(mGIFStruct);
|
||||
mGIFStruct = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void flush (); */
|
||||
NS_IMETHODIMP nsGIFDecoder2::Flush()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* static callback from nsIInputStream::ReadSegments */
|
||||
static NS_METHOD ReadDataOut(nsIInputStream* in,
|
||||
void* closure,
|
||||
const char* fromRawSegment,
|
||||
PRUint32 toOffset,
|
||||
PRUint32 count,
|
||||
PRUint32 *writeCount)
|
||||
{
|
||||
nsGIFDecoder2 *decoder = NS_STATIC_CAST(nsGIFDecoder2*, closure);
|
||||
nsresult rv = decoder->ProcessData((unsigned char*)fromRawSegment, count, writeCount);
|
||||
if (NS_FAILED(rv)) {
|
||||
*writeCount = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Push any new rows according to mCurrentPass/mLastFlushedPass and
|
||||
// mCurrentRow/mLastFlushedRow. Note: caller is responsible for
|
||||
// updating mlastFlushed{Row,Pass}.
|
||||
NS_METHOD
|
||||
nsGIFDecoder2::FlushImageData()
|
||||
{
|
||||
PRInt32 width;
|
||||
PRInt32 height;
|
||||
mImageFrame->GetWidth(&width);
|
||||
mImageFrame->GetHeight(&height);
|
||||
switch (mCurrentPass - mLastFlushedPass) {
|
||||
case 0: { // same pass
|
||||
PRInt32 remainingRows = mCurrentRow - mLastFlushedRow;
|
||||
if (remainingRows) {
|
||||
nsRect r(0, mLastFlushedRow+1, width, remainingRows);
|
||||
mObserver->OnDataAvailable(nsnull, nsnull, mImageFrame, &r);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: { // one pass on - need to handle bottom & top rects
|
||||
nsRect r(0, 0, width, mCurrentRow+1);
|
||||
mObserver->OnDataAvailable(nsnull, nsnull, mImageFrame, &r);
|
||||
nsRect r2(0, mLastFlushedRow+1, width, height-mLastFlushedRow-1);
|
||||
mObserver->OnDataAvailable(nsnull, nsnull, mImageFrame, &r2);
|
||||
}
|
||||
break;
|
||||
|
||||
default: { // more than one pass on - push the whole frame
|
||||
nsRect r(0, 0, width, height);
|
||||
mObserver->OnDataAvailable(nsnull, nsnull, mImageFrame, &r);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
nsresult nsGIFDecoder2::ProcessData(unsigned char *data, PRUint32 count, PRUint32 *_retval)
|
||||
{
|
||||
// Push the data to the GIF decoder
|
||||
|
||||
// First we ask if the gif decoder is ready for more data, and if so, push it.
|
||||
// In the new decoder, we should always be able to process more data since
|
||||
// we don't wait to decode each frame in an animation now.
|
||||
if (gif_write_ready(mGIFStruct)) {
|
||||
PRStatus result = gif_write(mGIFStruct, data, count);
|
||||
if (result != PR_SUCCESS)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mImageFrame && mObserver) {
|
||||
FlushImageData();
|
||||
mLastFlushedRow = mCurrentRow;
|
||||
mLastFlushedPass = mCurrentPass;
|
||||
}
|
||||
|
||||
*_retval = count;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* unsigned long writeFrom (in nsIInputStream inStr, in unsigned long count); */
|
||||
NS_IMETHODIMP nsGIFDecoder2::WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval)
|
||||
{
|
||||
return inStr->ReadSegments(ReadDataOut, this, count, _retval);
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// GIF decoder callback methods. Part of pulic API for GIF2
|
||||
//******************************************************************************
|
||||
|
||||
//******************************************************************************
|
||||
int BeginGIF(
|
||||
void* aClientData,
|
||||
PRUint32 aLogicalScreenWidth,
|
||||
PRUint32 aLogicalScreenHeight,
|
||||
PRUint8 aBackgroundRGBIndex)
|
||||
{
|
||||
// If we have passed an illogical screen size, bail and hope that we'll get
|
||||
// set later by the first frame's local image header.
|
||||
if(aLogicalScreenWidth == 0 || aLogicalScreenHeight == 0)
|
||||
return 0;
|
||||
|
||||
// copy GIF info into imagelib structs
|
||||
nsGIFDecoder2 *decoder = NS_STATIC_CAST(nsGIFDecoder2*, aClientData);
|
||||
|
||||
decoder->mBackgroundRGBIndex = aBackgroundRGBIndex;
|
||||
|
||||
if (decoder->mObserver)
|
||||
decoder->mObserver->OnStartDecode(nsnull, nsnull);
|
||||
|
||||
decoder->mImageContainer->Init(aLogicalScreenWidth, aLogicalScreenHeight, decoder->mObserver);
|
||||
|
||||
if (decoder->mObserver)
|
||||
decoder->mObserver->OnStartContainer(nsnull, nsnull, decoder->mImageContainer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int EndGIF(
|
||||
void* aClientData,
|
||||
int aAnimationLoopCount)
|
||||
{
|
||||
nsGIFDecoder2 *decoder = NS_STATIC_CAST(nsGIFDecoder2*, aClientData);
|
||||
if (decoder->mObserver) {
|
||||
decoder->mObserver->OnStopContainer(nsnull, nsnull, decoder->mImageContainer);
|
||||
decoder->mObserver->OnStopDecode(nsnull, nsnull, NS_OK, nsnull);
|
||||
}
|
||||
|
||||
decoder->mImageContainer->SetLoopCount(aAnimationLoopCount);
|
||||
decoder->mImageContainer->DecodingComplete();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int BeginImageFrame(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber, /* Frame number, 1-n */
|
||||
PRUint32 aFrameXOffset, /* X offset in logical screen */
|
||||
PRUint32 aFrameYOffset, /* Y offset in logical screen */
|
||||
PRUint32 aFrameWidth,
|
||||
PRUint32 aFrameHeight,
|
||||
GIF_RGB* aTransparencyChromaKey) /* don't have this info yet */
|
||||
{
|
||||
nsGIFDecoder2* decoder = NS_STATIC_CAST(nsGIFDecoder2*, aClientData);
|
||||
|
||||
decoder->mImageFrame = nsnull; // clear out our current frame reference
|
||||
decoder->mGIFStruct->x_offset = aFrameXOffset;
|
||||
decoder->mGIFStruct->y_offset = aFrameYOffset;
|
||||
decoder->mGIFStruct->width = aFrameWidth;
|
||||
decoder->mGIFStruct->height = aFrameHeight;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int EndImageFrame(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber,
|
||||
PRUint32 aDelayTimeout,
|
||||
PRUint32 aDisposal) /* Time this frame should be displayed before the next frame
|
||||
we can't have this in the image frame init because it doesn't
|
||||
show up in the GIF frame header, it shows up in a sub control
|
||||
block.*/
|
||||
{
|
||||
nsGIFDecoder2* decoder = NS_STATIC_CAST(nsGIFDecoder2*, aClientData);
|
||||
|
||||
// We actually have the timeout information before we get the lzw encoded image
|
||||
// data, at least according to the spec, but we delay in setting the timeout for
|
||||
// the image until here to help ensure that we have the whole image frame decoded before
|
||||
// we go off and try to display another frame.
|
||||
decoder->mImageContainer->EndFrameDecode(aFrameNumber, aDelayTimeout);
|
||||
|
||||
if (decoder->mObserver && decoder->mImageFrame) {
|
||||
decoder->mImageFrame->SetFrameDisposalMethod(aDisposal);
|
||||
|
||||
decoder->FlushImageData();
|
||||
|
||||
decoder->mCurrentRow = decoder->mLastFlushedRow = -1;
|
||||
decoder->mCurrentPass = decoder->mLastFlushedPass = 0;
|
||||
|
||||
decoder->mObserver->OnStopFrame(nsnull, nsnull, decoder->mImageFrame);
|
||||
}
|
||||
|
||||
decoder->mImageFrame = nsnull;
|
||||
decoder->mGIFStruct->local_colormap = nsnull;
|
||||
decoder->mGIFStruct->is_transparent = PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// GIF decoder callback
|
||||
int HaveImageAll(
|
||||
void* aClientData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
// GIF decoder callback notification that it has decoded a row
|
||||
int HaveDecodedRow(
|
||||
void* aClientData,
|
||||
PRUint8* aRowBufPtr, // Pointer to single scanline temporary buffer
|
||||
int aXOffset, // With respect to GIF logical screen origin
|
||||
int aLength, // Length of the row?
|
||||
int aRowNumber, // Row number?
|
||||
int aDuplicateCount, // Number of times to duplicate the row?
|
||||
PRUint8 aDrawMode, // il_draw_mode
|
||||
int aInterlacePass) // interlace pass (1-4)
|
||||
{
|
||||
nsGIFDecoder2* decoder = NS_STATIC_CAST(nsGIFDecoder2*, aClientData);
|
||||
PRUint32 bpr, abpr;
|
||||
// We have to delay allocation of the image frame until now because
|
||||
// we won't have control block info (transparency) until now. The conrol
|
||||
// block of a GIF stream shows up after the image header since transparency
|
||||
// is added in GIF89a and control blocks are how the extensions are done.
|
||||
// How annoying.
|
||||
if(! decoder->mImageFrame) {
|
||||
gfx_format format = gfxIFormats::RGB;
|
||||
if (decoder->mGIFStruct->is_transparent) {
|
||||
format = gfxIFormats::RGB_A1;
|
||||
}
|
||||
|
||||
#if defined(XP_PC) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON)
|
||||
// XXX this works...
|
||||
format += 1; // RGB to BGR
|
||||
#endif
|
||||
|
||||
// initalize the frame and append it to the container
|
||||
decoder->mImageFrame = do_CreateInstance("@mozilla.org/gfx/image/frame;2");
|
||||
decoder->mImageFrame->Init(
|
||||
decoder->mGIFStruct->x_offset, decoder->mGIFStruct->y_offset,
|
||||
decoder->mGIFStruct->width, decoder->mGIFStruct->height, format);
|
||||
|
||||
decoder->mImageContainer->AppendFrame(decoder->mImageFrame);
|
||||
|
||||
if (decoder->mObserver)
|
||||
decoder->mObserver->OnStartFrame(nsnull, nsnull, decoder->mImageFrame);
|
||||
|
||||
decoder->mImageFrame->GetImageBytesPerRow(&bpr);
|
||||
decoder->mImageFrame->GetAlphaBytesPerRow(&abpr);
|
||||
|
||||
decoder->mRGBLine = (PRUint8 *)nsMemory::Realloc(decoder->mRGBLine, bpr);
|
||||
|
||||
if (format == gfxIFormats::RGB_A1 || format == gfxIFormats::BGR_A1) {
|
||||
decoder->mAlphaLine = (PRUint8 *)nsMemory::Realloc(decoder->mAlphaLine, abpr);
|
||||
}
|
||||
} else {
|
||||
decoder->mImageFrame->GetImageBytesPerRow(&bpr);
|
||||
decoder->mImageFrame->GetAlphaBytesPerRow(&abpr);
|
||||
}
|
||||
|
||||
if (aRowBufPtr) {
|
||||
nscoord width;
|
||||
|
||||
decoder->mImageFrame->GetWidth(&width);
|
||||
PRUint32 iwidth = width;
|
||||
|
||||
gfx_format format;
|
||||
decoder->mImageFrame->GetFormat(&format);
|
||||
|
||||
// XXX map the data into colors
|
||||
int cmapsize;
|
||||
GIF_RGB* cmap;
|
||||
cmapsize = decoder->mGIFStruct->global_colormap_size;
|
||||
cmap = decoder->mGIFStruct->global_colormap;
|
||||
|
||||
if(decoder->mGIFStruct->global_colormap &&
|
||||
decoder->mGIFStruct->screen_bgcolor < cmapsize) {
|
||||
gfx_color bgColor = 0;
|
||||
bgColor |= cmap[decoder->mGIFStruct->screen_bgcolor].red;
|
||||
bgColor |= cmap[decoder->mGIFStruct->screen_bgcolor].green << 8;
|
||||
bgColor |= cmap[decoder->mGIFStruct->screen_bgcolor].blue << 16;
|
||||
decoder->mImageFrame->SetBackgroundColor(bgColor);
|
||||
}
|
||||
if(decoder->mGIFStruct->local_colormap) {
|
||||
cmapsize = decoder->mGIFStruct->local_colormap_size;
|
||||
cmap = decoder->mGIFStruct->local_colormap;
|
||||
}
|
||||
|
||||
PRUint8* rgbRowIndex = decoder->mRGBLine;
|
||||
PRUint8* rowBufIndex = aRowBufPtr;
|
||||
|
||||
switch (format) {
|
||||
case gfxIFormats::RGB:
|
||||
{
|
||||
while(rowBufIndex != decoder->mGIFStruct->rowend) {
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
|
||||
#endif
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].red;
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].green;
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].blue;
|
||||
++rowBufIndex;
|
||||
}
|
||||
|
||||
for (int i=0; i<aDuplicateCount; i++)
|
||||
decoder->mImageFrame->SetImageData(decoder->mRGBLine,
|
||||
bpr, (aRowNumber+i)*bpr);
|
||||
}
|
||||
break;
|
||||
case gfxIFormats::BGR:
|
||||
{
|
||||
while(rowBufIndex != decoder->mGIFStruct->rowend) {
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].blue;
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].green;
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].red;
|
||||
++rowBufIndex;
|
||||
}
|
||||
|
||||
for (int i=0; i<aDuplicateCount; i++)
|
||||
decoder->mImageFrame->SetImageData(decoder->mRGBLine,
|
||||
bpr, (aRowNumber+i)*bpr);
|
||||
}
|
||||
break;
|
||||
case gfxIFormats::RGB_A1:
|
||||
case gfxIFormats::BGR_A1:
|
||||
{
|
||||
if (decoder->mGIFStruct->is_transparent &&
|
||||
(decoder->mGIFStruct->tpixel < cmapsize)) {
|
||||
gfx_color transColor = 0;
|
||||
transColor |= cmap[decoder->mGIFStruct->tpixel].red;
|
||||
transColor |= cmap[decoder->mGIFStruct->tpixel].green << 8;
|
||||
transColor |= cmap[decoder->mGIFStruct->tpixel].blue << 16;
|
||||
decoder->mImageFrame->SetTransparentColor(transColor);
|
||||
}
|
||||
|
||||
memset(decoder->mRGBLine, 0, bpr);
|
||||
memset(decoder->mAlphaLine, 0, abpr);
|
||||
PRUint32 iwidth = (PRUint32)width;
|
||||
for (PRUint32 x=0; x<iwidth; x++) {
|
||||
if (*rowBufIndex != decoder->mGIFStruct->tpixel) {
|
||||
#if defined(XP_PC) || defined(XP_BEOS) || defined(MOZ_WIDGET_PHOTON)
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].blue;
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].green;
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].red;
|
||||
#else
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
|
||||
#endif
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].red;
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].green;
|
||||
*rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].blue;
|
||||
#endif
|
||||
decoder->mAlphaLine[x>>3] |= 1<<(7-x&0x7);
|
||||
} else {
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
rgbRowIndex+=4;
|
||||
#else
|
||||
rgbRowIndex+=3;
|
||||
#endif
|
||||
}
|
||||
|
||||
++rowBufIndex;
|
||||
}
|
||||
for (int i=0; i<aDuplicateCount; i++) {
|
||||
decoder->mImageFrame->SetAlphaData(decoder->mAlphaLine,
|
||||
abpr, (aRowNumber+i)*abpr);
|
||||
decoder->mImageFrame->SetImageData(decoder->mRGBLine,
|
||||
bpr, (aRowNumber+i)*bpr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
decoder->mCurrentRow = aRowNumber+aDuplicateCount-1;
|
||||
decoder->mCurrentPass = aInterlacePass;
|
||||
if (aInterlacePass == 1)
|
||||
decoder->mLastFlushedPass = aInterlacePass; // interlaced starts at 1
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int ResetPalette()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int SetupColorspaceConverter()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int EndImageFrame()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int NewPixmap()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int InitTransparentPixel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
int DestroyTransparentPixel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Saari <saari@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _nsGIFDecoder2_h
|
||||
#define _nsGIFDecoder2_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "imgIDecoder.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIDecoderObserver.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
|
||||
#include "GIF2.h"
|
||||
|
||||
#define NS_GIFDECODER2_CID \
|
||||
{ /* 797bec5a-1dd2-11b2-a7f8-ca397e0179c4 */ \
|
||||
0x797bec5a, \
|
||||
0x1dd2, \
|
||||
0x11b2, \
|
||||
{0xa7, 0xf8, 0xca, 0x39, 0x7e, 0x01, 0x79, 0xc4} \
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// nsGIFDecoder2 Definition
|
||||
|
||||
class nsGIFDecoder2 : public imgIDecoder
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGIDECODER
|
||||
|
||||
nsGIFDecoder2();
|
||||
virtual ~nsGIFDecoder2();
|
||||
|
||||
nsresult ProcessData(unsigned char *data, PRUint32 count, PRUint32 *_retval);
|
||||
|
||||
NS_METHOD FlushImageData();
|
||||
|
||||
nsCOMPtr<imgIContainer> mImageContainer;
|
||||
nsCOMPtr<gfxIImageFrame> mImageFrame;
|
||||
nsCOMPtr<imgIDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
|
||||
PRInt32 mCurrentRow;
|
||||
PRInt32 mLastFlushedRow;
|
||||
|
||||
gif_struct *mGIFStruct;
|
||||
|
||||
PRUint8 *mAlphaLine;
|
||||
PRUint8 *mRGBLine;
|
||||
PRUint8 mBackgroundRGBIndex;
|
||||
PRUint8 mCurrentPass;
|
||||
PRUint8 mLastFlushedPass;
|
||||
};
|
||||
|
||||
// static callbacks for the GIF decoder
|
||||
static int PR_CALLBACK BeginGIF(
|
||||
void* aClientData,
|
||||
PRUint32 aLogicalScreenWidth,
|
||||
PRUint32 aLogicalScreenHeight,
|
||||
PRUint8 aBackgroundRGBIndex);
|
||||
|
||||
static int PR_CALLBACK HaveDecodedRow(
|
||||
void* aClientData,
|
||||
PRUint8* aRowBufPtr, // Pointer to single scanline temporary buffer
|
||||
int aXOffset, // With respect to GIF logical screen origin
|
||||
int aLength, // Length of the row?
|
||||
int aRow, // Row number?
|
||||
int aDuplicateCount, // Number of times to duplicate the row?
|
||||
PRUint8 aDrawMode, // il_draw_mode
|
||||
int aInterlacePass);
|
||||
|
||||
static int PR_CALLBACK NewPixmap();
|
||||
|
||||
static int PR_CALLBACK EndGIF(
|
||||
void* aClientData,
|
||||
int aAnimationLoopCount);
|
||||
|
||||
static int PR_CALLBACK BeginImageFrame(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber, /* Frame number, 1-n */
|
||||
PRUint32 aFrameXOffset, /* X offset in logical screen */
|
||||
PRUint32 aFrameYOffset, /* Y offset in logical screen */
|
||||
PRUint32 aFrameWidth,
|
||||
PRUint32 aFrameHeight,
|
||||
GIF_RGB* aTransparencyChromaKey);
|
||||
static int PR_CALLBACK EndImageFrame(
|
||||
void* aClientData,
|
||||
PRUint32 aFrameNumber,
|
||||
PRUint32 aDelayTimeout,
|
||||
PRUint32 aDisposal);
|
||||
static int PR_CALLBACK SetupColorspaceConverter();
|
||||
static int PR_CALLBACK ResetPalette();
|
||||
static int PR_CALLBACK InitTransparentPixel();
|
||||
static int PR_CALLBACK DestroyTransparentPixel();
|
||||
|
||||
static int PR_CALLBACK HaveImageAll(
|
||||
void* aClientData);
|
||||
#endif
|
||||
@@ -1,64 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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):
|
||||
* Chris Saari <saari@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsGIFDecoder2.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGifAllocator.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsGIFDecoder2)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "GIF Decoder",
|
||||
NS_GIFDECODER2_CID,
|
||||
"@mozilla.org/image/decoder;2?type=image/gif",
|
||||
nsGIFDecoder2Constructor, },
|
||||
};
|
||||
|
||||
// GIF module shutdown hook
|
||||
static void PR_CALLBACK nsGifShutdown(nsIModule *module)
|
||||
{
|
||||
// Release cached buffers from zlib allocator
|
||||
delete gGifAllocator;
|
||||
}
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_DTOR(nsGIFModule2, components, nsGifShutdown);
|
||||
|
||||
@@ -1,104 +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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 ***** */
|
||||
|
||||
/*
|
||||
* Allocator optimized for use with gif decoder
|
||||
*
|
||||
* For every image that gets loaded, we allocate
|
||||
* 4097 x 2 : gs->prefix
|
||||
* 4097 x 1 : gs->suffix
|
||||
* 4097 x 1 : gs->stack
|
||||
* for lzw to operate on the data. These are held for a very short interval
|
||||
* and freed. This allocator tries to keep one set of these around
|
||||
* and reuses them; automatically fails over to use calloc/free when all
|
||||
* buckets are full.
|
||||
*/
|
||||
|
||||
#include "prlock.h"
|
||||
#include "prlog.h"
|
||||
|
||||
class nsGifAllocator;
|
||||
extern nsGifAllocator *gGifAllocator;
|
||||
|
||||
const PRInt32 kNumBuckets = 3;
|
||||
|
||||
class nsGifAllocator {
|
||||
protected:
|
||||
void *mMemBucket[kNumBuckets];
|
||||
PRUint32 mSize[kNumBuckets];
|
||||
PRLock *mLock;
|
||||
PRUint32 mFlag;
|
||||
|
||||
public:
|
||||
nsGifAllocator() : mFlag(0), mLock(nsnull)
|
||||
{
|
||||
memset(mMemBucket, 0, sizeof mMemBucket);
|
||||
memset(mSize, 0, sizeof mSize);
|
||||
mLock = PR_NewLock();
|
||||
PR_ASSERT(mLock != NULL);
|
||||
}
|
||||
|
||||
~nsGifAllocator()
|
||||
{
|
||||
ClearBuckets();
|
||||
if (mLock)
|
||||
PR_DestroyLock(mLock);
|
||||
}
|
||||
|
||||
// Gif allocators
|
||||
void* Calloc(PRUint32 items, PRUint32 size);
|
||||
void Free(void *ptr);
|
||||
// Clear all buckets of memory
|
||||
void ClearBuckets();
|
||||
|
||||
// in-use flag getters/setters
|
||||
inline PRBool IsUsed(PRUint32 i)
|
||||
{
|
||||
PR_ASSERT(i <= 31);
|
||||
return mFlag & (1 << i);
|
||||
}
|
||||
inline void MarkUsed(PRUint32 i)
|
||||
{
|
||||
PR_ASSERT(i <= 31);
|
||||
mFlag |= (1 << i);
|
||||
}
|
||||
inline void ClearUsed(PRUint32 i)
|
||||
{
|
||||
PR_ASSERT(i <= 31);
|
||||
mFlag &= ~(1 << i);
|
||||
}
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
?Release@nsGIFDecoder2@@UAGKXZ ; 9300
|
||||
?AddRef@nsGIFDecoder2@@UAGKXZ ; 9300
|
||||
?ProcessData@nsGIFDecoder2@@QAGIPAEI@Z ; 6722
|
||||
?gif_write_ready@@YAEPAUgif_struct@@@Z ; 6722
|
||||
?gif_write@@YAHPAUgif_struct@@PBEI@Z ; 6722
|
||||
?WriteFrom@nsGIFDecoder2@@UAGIPAVnsIInputStream@@IPAI@Z ; 4869
|
||||
?gif_destroy@@YAXPAUgif_struct@@@Z ; 4650
|
||||
?QueryInterface@nsGIFDecoder2@@UAGIABUnsID@@PAPAX@Z ; 4650
|
||||
?Init@nsGIFDecoder2@@UAGIPAVimgIRequest@@@Z ; 4650
|
||||
??_EnsGIFDecoder2@@UAEPAXI@Z ; 4650
|
||||
?Close@nsGIFDecoder2@@UAGIXZ ; 4650
|
||||
??0nsGIFDecoder2@@QAE@XZ ; 4650
|
||||
??1nsGIFDecoder2@@UAE@XZ ; 4650
|
||||
?GIFInit@@YAHPAUgif_struct@@PAXP6AHXZP6AH1IIE@ZP6AH1H@ZP6AH1IIIIIPAU_GIF_RGB@@@ZP6AH1III@Z2222P6AH1PAE8HHHHEH@ZP6AH1@Z@Z ; 4650
|
||||
?gif_create@@YAHPAPAUgif_struct@@@Z ; 4650
|
||||
?Flush@nsGIFDecoder2@@UAGIXZ ; 4650
|
||||
?il_BACat@@YAPADPAPADIPBDI@Z ; 4124
|
||||
NSGetModule ; 1
|
||||
9
mozilla/xpinstall/wizard/unix/src2/.LIBSREQD.list
Normal file
9
mozilla/xpinstall/wizard/unix/src2/.LIBSREQD.list
Normal file
@@ -0,0 +1,9 @@
|
||||
libjar50.so
|
||||
libjsdom.so
|
||||
libmozjs.so
|
||||
libnspr3.so
|
||||
libplc3.so
|
||||
libplds3.so
|
||||
libxpcom.so
|
||||
libxpinstall.so
|
||||
libxpistub.so
|
||||
352
mozilla/xpinstall/wizard/unix/src2/INSTALL.cpp
Normal file
352
mozilla/xpinstall/wizard/unix/src2/INSTALL.cpp
Normal file
@@ -0,0 +1,352 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1999
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "INSTALL.h"
|
||||
|
||||
static xpistub_t gstub;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int err = XI_OK;
|
||||
xpi_t *pkglist;
|
||||
|
||||
ERR_CHECK( init() );
|
||||
ERR_CHECK( build_list(&pkglist) );
|
||||
ERR_CHECK( install_all(pkglist) );
|
||||
ERR_CHECK( shutdown(pkglist) );
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
init()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
char progdir[512];
|
||||
int err = XI_OK;
|
||||
DUMP("initialize");
|
||||
|
||||
err = extract_core();
|
||||
if (err != XI_OK)
|
||||
{
|
||||
PRINT_ERR(err);
|
||||
shutdown(NULL);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = load_stub();
|
||||
if (err != XI_OK)
|
||||
{
|
||||
PRINT_ERR(err);
|
||||
shutdown(NULL);
|
||||
return err;
|
||||
}
|
||||
|
||||
getcwd(progdir, 512);
|
||||
rv = gstub.fn_init(progdir, progress_callback);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
PRINT_ERR(rv);
|
||||
shutdown(NULL);
|
||||
return XI_XPI_FAIL;
|
||||
}
|
||||
DUMP("XPI_Init called");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
extract_core()
|
||||
{
|
||||
char cmd[256];
|
||||
int i;
|
||||
int err = XI_OK;
|
||||
DUMP("extract_core");
|
||||
|
||||
for (i = 0; i < CORE_LIB_COUNT*2; i++)
|
||||
{
|
||||
strcpy(cmd, "unzip -j "); /* -j = junk paths; install here */
|
||||
strcat(cmd, CORE_ARCHIVE); /* relative path to install.xpi */
|
||||
strcat(cmd, " -d . "); /* -d = destination root */
|
||||
strcat(cmd, core_libs[i]); /* archive subdir */
|
||||
strcat(cmd, core_libs[++i]);/* lib file name */
|
||||
strcat(cmd, "\0");
|
||||
DUMP(cmd);
|
||||
|
||||
system(cmd);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
load_stub()
|
||||
{
|
||||
char libpath[512];
|
||||
char *dlerr;
|
||||
int err = XI_OK;
|
||||
DUMP("load_stub");
|
||||
|
||||
/* get the working dir and tack on lib name */
|
||||
getcwd(libpath, 512);
|
||||
strncat(libpath, "/", 1);
|
||||
strncat(libpath, XPISTUB, strlen(XPISTUB));
|
||||
DUMP(libpath);
|
||||
|
||||
/* open the library */
|
||||
gstub.handle = NULL;
|
||||
gstub.handle = dlopen(libpath, RTLD_NOW);
|
||||
if (!gstub.handle)
|
||||
{
|
||||
dlerr = dlerror();
|
||||
DUMP(dlerr);
|
||||
return XI_LIB_OPEN;
|
||||
}
|
||||
DUMP("xpistub opened");
|
||||
|
||||
/* read and store symbol addresses */
|
||||
gstub.fn_init = (pfnXPI_Init) dlsym(gstub.handle, FN_INIT);
|
||||
gstub.fn_install = (pfnXPI_Install) dlsym(gstub.handle, FN_INSTALL);
|
||||
gstub.fn_exit = (pfnXPI_Exit) dlsym(gstub.handle, FN_EXIT);
|
||||
if (!gstub.fn_init || !gstub.fn_install || !gstub.fn_exit)
|
||||
{
|
||||
dlerr = dlerror();
|
||||
DUMP(dlerr);
|
||||
return XI_LIB_SYM;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
progress_callback(const char* msg, PRInt32 max, PRInt32 val)
|
||||
{
|
||||
DUMP("progress_callback");
|
||||
if (max == 0)
|
||||
{
|
||||
if (val > 0)
|
||||
printf("Preparing item %d ...\n", val);
|
||||
}
|
||||
else
|
||||
printf("Installing item %d of %d ...\n", val, max);
|
||||
}
|
||||
|
||||
int
|
||||
build_list(xpi_t **listhead)
|
||||
{
|
||||
xpi_t *currxpi = NULL, *lastxpi = NULL;
|
||||
char mfpath[512];
|
||||
char *buf = NULL, *pcurr, curr[32];
|
||||
fpos_t mfeof;
|
||||
FILE *fdmf;
|
||||
size_t rd = 0;
|
||||
int len = 0, total, head;
|
||||
int err = XI_OK;
|
||||
DUMP("build_list");
|
||||
|
||||
if (!listhead)
|
||||
return XI_NULL_PTR;
|
||||
|
||||
*listhead = NULL;
|
||||
|
||||
/* XXX optionally set mf path in cmd line args */
|
||||
strcpy(mfpath, MANIFEST);
|
||||
|
||||
/* open manifest file */
|
||||
fdmf = NULL;
|
||||
fdmf = fopen(mfpath, "r");
|
||||
if (!fdmf)
|
||||
{
|
||||
err = XI_NO_MANIFEST;
|
||||
goto bail;
|
||||
}
|
||||
DUMP("opened manifest");
|
||||
|
||||
/* read the file into a buffer */
|
||||
if (fseek(fdmf, 0, SEEK_END) != 0)
|
||||
{
|
||||
err = XI_NO_MANIFEST;
|
||||
goto bail;
|
||||
}
|
||||
if (fgetpos(fdmf, &mfeof) != 0)
|
||||
{
|
||||
err = XI_NO_MANIFEST;
|
||||
goto bail;
|
||||
}
|
||||
DUMP("eof manifest found");
|
||||
|
||||
buf = (char*) malloc(mfeof * sizeof(char));
|
||||
if (!buf)
|
||||
{
|
||||
err = XI_OUT_OF_MEM;
|
||||
goto bail;
|
||||
}
|
||||
DUMP("malloc'd manifest buf");
|
||||
|
||||
if (fseek(fdmf, 0, SEEK_SET) != 0)
|
||||
{
|
||||
err = XI_NO_MANIFEST;
|
||||
goto bail;
|
||||
}
|
||||
rd = fread( (void*)buf, 1, mfeof, fdmf);
|
||||
if (!rd)
|
||||
{
|
||||
err = XI_NO_MANIFEST;
|
||||
goto bail;
|
||||
}
|
||||
DUMP(buf);
|
||||
|
||||
/* loop over each line reading in a .xpi module
|
||||
* name unless commented with ';'
|
||||
*/
|
||||
head = 1;
|
||||
for (pcurr = buf, total = 0; total < mfeof; pcurr = strchr(pcurr, '\n')+1)
|
||||
{
|
||||
len = strchr(pcurr, '\n') - pcurr;
|
||||
total += len + 1;
|
||||
strncpy(curr, pcurr, len);
|
||||
curr[ (len>32?32:len) ] = '\0';
|
||||
|
||||
/* malloc a new xpi structure */
|
||||
currxpi = (xpi_t *) malloc(sizeof(xpi_t));
|
||||
if (!currxpi)
|
||||
{
|
||||
err = XI_OUT_OF_MEM;
|
||||
goto bail;
|
||||
}
|
||||
currxpi->next = NULL;
|
||||
if (head)
|
||||
{
|
||||
*listhead = currxpi;
|
||||
lastxpi = currxpi;
|
||||
}
|
||||
strncpy(currxpi->name, curr, (len>32?32:len));
|
||||
|
||||
/* link to xpi list */
|
||||
if (!head && *listhead)
|
||||
{
|
||||
lastxpi->next = currxpi;
|
||||
lastxpi = currxpi;
|
||||
}
|
||||
else
|
||||
head = 0;
|
||||
}
|
||||
|
||||
/* close manifest file */
|
||||
fclose(fdmf);
|
||||
|
||||
return err;
|
||||
|
||||
bail:
|
||||
if (buf)
|
||||
free(buf);
|
||||
shutdown(*listhead);
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
install_all(xpi_t *listhead)
|
||||
{
|
||||
xpi_t *curr = listhead;
|
||||
int err = XI_OK;
|
||||
DUMP("install_all");
|
||||
|
||||
if (!listhead)
|
||||
return XI_NULL_PTR;
|
||||
|
||||
while (curr)
|
||||
{
|
||||
install_one(curr);
|
||||
curr = curr->next;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
install_one(xpi_t *pkg)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
char xpipath[512];
|
||||
int err = XI_OK;
|
||||
DUMP("install_one");
|
||||
|
||||
getcwd(xpipath, 512);
|
||||
strncat(xpipath, "/modules/", 9);
|
||||
strncat(xpipath, pkg->name, strlen(pkg->name));
|
||||
|
||||
DUMP("--------- installing xpi package: ");
|
||||
DUMP(xpipath);
|
||||
DUMP("---------\n");
|
||||
|
||||
/* XXX check if file exists: if not skip it with status */
|
||||
|
||||
rv = gstub.fn_install(xpipath, "", 0);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
err = XI_XPI_FAIL;
|
||||
printf("ERROR %d: Installation of %s failed.\n", rv, pkg->name);
|
||||
}
|
||||
else
|
||||
printf("Installed %s successfully.\n", pkg->name);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
shutdown(xpi_t *list)
|
||||
{
|
||||
xpi_t *curr = list;
|
||||
int i;
|
||||
int err = XI_OK;
|
||||
DUMP("shutdown");
|
||||
|
||||
/* release XPCOM and XPInstall */
|
||||
if (gstub.fn_exit)
|
||||
{
|
||||
gstub.fn_exit();
|
||||
DUMP("XPI_Exit called");
|
||||
}
|
||||
|
||||
/* close xpistub library */
|
||||
if (gstub.handle)
|
||||
{
|
||||
dlclose(gstub.handle);
|
||||
DUMP("xpistub closed");
|
||||
}
|
||||
|
||||
while (curr)
|
||||
{
|
||||
list = curr->next;
|
||||
free(curr);
|
||||
curr = list;
|
||||
}
|
||||
|
||||
/* clean up extracted core libs */
|
||||
for (i=1; i<CORE_LIB_COUNT*2; i+=2)
|
||||
{
|
||||
unlink(core_libs[i]);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
136
mozilla/xpinstall/wizard/unix/src2/INSTALL.h
Normal file
136
mozilla/xpinstall/wizard/unix/src2/INSTALL.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1999
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _INSTALL_H_
|
||||
#define _INSTALL_H_
|
||||
|
||||
#include "xpistub.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
/*_____________________________________________ func ptrs __*/
|
||||
typedef nsresult (*pfnXPI_Init) (const char *aProgramDir, pfnXPIProgress progressCB);
|
||||
typedef nsresult (*pfnXPI_Install) (const char *file, const char *args, long flags);
|
||||
typedef void (*pfnXPI_Exit) ();
|
||||
|
||||
/*________________________________________________ arrays __*/
|
||||
#define CORE_LIB_COUNT 10
|
||||
static char core_libs[CORE_LIB_COUNT*2][32] =
|
||||
{
|
||||
/* Archive Subdir File */
|
||||
/* -------------- ---- */
|
||||
"bin/", "libjsdom.so",
|
||||
"bin/", "libmozjs.so",
|
||||
"bin/", "libnspr3.so",
|
||||
"bin/", "libplc3.so",
|
||||
"bin/", "libplds3.so",
|
||||
"bin/", "libxpcom.so",
|
||||
"bin/", "libxpistub.so",
|
||||
"bin/components/", "libxpinstall.so",
|
||||
"bin/components/", "libjar50.so",
|
||||
"bin/", "component.reg"
|
||||
};
|
||||
|
||||
/*_______________________________________________ structs __*/
|
||||
typedef struct _xpistub_t
|
||||
{
|
||||
const char *name;
|
||||
void *handle;
|
||||
pfnXPI_Init fn_init;
|
||||
pfnXPI_Install fn_install;
|
||||
pfnXPI_Exit fn_exit;
|
||||
} xpistub_t;
|
||||
|
||||
typedef struct _xpi_t
|
||||
{
|
||||
char name[32];
|
||||
struct _xpi_t *next;
|
||||
} xpi_t;
|
||||
|
||||
/*_________________________________________________ funcs __*/
|
||||
int main(int argc, char **argv);
|
||||
int init();
|
||||
int extract_core();
|
||||
int load_stub();
|
||||
void progress_callback(const char *msg, PRInt32 max, PRInt32 val);
|
||||
int build_list(xpi_t **listhead);
|
||||
int install_all(xpi_t *listhead);
|
||||
int install_one(xpi_t *pkg);
|
||||
int shutdown(xpi_t *list);
|
||||
|
||||
/*________________________________________________ macros __*/
|
||||
#ifdef DEBUG_sgehani___
|
||||
#define DUMP(_msg) \
|
||||
printf("%s %d: ", __FILE__, __LINE__); \
|
||||
printf(_msg); \
|
||||
printf("\n");
|
||||
#else
|
||||
#define DUMP(_msg)
|
||||
#endif
|
||||
|
||||
#define XPISTUB "libxpistub.so"
|
||||
#define FN_INIT "XPI_Init"
|
||||
#define FN_INSTALL "XPI_Install"
|
||||
#define FN_EXIT "XPI_Exit"
|
||||
|
||||
#ifndef RTLD_NOW
|
||||
#define RTLD_NOW 0
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define CORE_ARCHIVE "modules/install.xpi"
|
||||
#define MANIFEST "modules/MANIFEST"
|
||||
|
||||
#define ERR_CHECK(_func) \
|
||||
{ \
|
||||
int ret_err = XI_OK; \
|
||||
ret_err = _func; \
|
||||
if (ret_err != XI_OK) \
|
||||
{ \
|
||||
PRINT_ERR(ret_err); \
|
||||
return ret_err; \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef DEBUG_sgehani
|
||||
#define PRINT_ERR(_err) \
|
||||
printf("%s %d: err = %d \n", __FILE__, __LINE__, _err);
|
||||
#endif
|
||||
|
||||
/*________________________________________________ errors __*/
|
||||
#define XI_OK 0
|
||||
#define XI_NULL_PTR -1
|
||||
#define XI_OUT_OF_MEM -2
|
||||
#define XI_FAIL -3
|
||||
#define XI_LIB_OPEN -4
|
||||
#define XI_LIB_SYM -5
|
||||
#define XI_XPI_FAIL -6
|
||||
#define XI_NO_MANIFEST -7
|
||||
|
||||
#endif /* _INSTALL_H_ */
|
||||
47
mozilla/xpinstall/wizard/unix/src2/Makefile.in
Normal file
47
mozilla/xpinstall/wizard/unix/src2/Makefile.in
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Samir Gehani <sgehani@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
PROGRAM = MozInstaller
|
||||
|
||||
CPPSRCS = \
|
||||
nsXInstallerDlg.cpp \
|
||||
nsComponent.cpp \
|
||||
nsSetupType.cpp \
|
||||
nsComponentList.cpp \
|
||||
nsLicenseDlg.cpp \
|
||||
nsWelcomeDlg.cpp \
|
||||
nsSetupTypeDlg.cpp \
|
||||
nsComponentsDlg.cpp \
|
||||
nsInstallDlg.cpp \
|
||||
nsXInstaller.cpp \
|
||||
nsINIParser.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
51
mozilla/xpinstall/wizard/unix/src2/XIErrors.h
Normal file
51
mozilla/xpinstall/wizard/unix/src2/XIErrors.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _XI_ERRORS_H_
|
||||
#define _XI_ERRORS_H_
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
* X Installer Errors
|
||||
*------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
OK = 0,
|
||||
E_MEM = -601, /* out of memory */
|
||||
E_PARAM = -602, /* invalid param */
|
||||
E_NO_MEMBER = -603 /* invalid member variable */
|
||||
};
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif /* _XI_ERRORS_H_ */
|
||||
32
mozilla/xpinstall/wizard/unix/src2/XILimits.h
Normal file
32
mozilla/xpinstall/wizard/unix/src2/XILimits.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _XILIMITS_H_
|
||||
#define _XILIMITS_H_
|
||||
|
||||
#define MAX_COMPONENTS 64
|
||||
#define MAX_SETUP_TYPES 32
|
||||
|
||||
|
||||
#endif /* _XILIMITS_H_ */
|
||||
17
mozilla/xpinstall/wizard/unix/src2/config.ini
Normal file
17
mozilla/xpinstall/wizard/unix/src2/config.ini
Normal file
@@ -0,0 +1,17 @@
|
||||
[section1]
|
||||
key1=value_of_key1_of_section1
|
||||
key2=value_of_key2_of_section1
|
||||
|
||||
[section2]
|
||||
key1=value_of_key1_of_section2
|
||||
; key2=commentvalue_of_key2_of_section2
|
||||
key2=realvalue_of_key2_of_section2
|
||||
|
||||
|
||||
; dhdks
|
||||
; kjdsakjdas
|
||||
[SetupType0]
|
||||
Short Description=Browser
|
||||
Long Description=This is the browser component.
|
||||
Size=9090
|
||||
|
||||
32
mozilla/xpinstall/wizard/unix/src2/ftptest.c
Normal file
32
mozilla/xpinstall/wizard/unix/src2/ftptest.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int arc, char **argv)
|
||||
{
|
||||
char *ftphost = "sweetlou";
|
||||
char *file = "/products/server/README";
|
||||
char *basename = "./README";
|
||||
char *user = "test";
|
||||
char *localhost = "test.com";
|
||||
char *ftpcmds = malloc(1024);
|
||||
|
||||
sprintf(ftpcmds, "\
|
||||
\
|
||||
ftp -n %s <<EndFTP\n\
|
||||
binary\n\
|
||||
user anonymous %s@%s\n\
|
||||
get %s %s\n\
|
||||
EndFTP\n\
|
||||
\
|
||||
", ftphost, user, localhost, file, basename);
|
||||
|
||||
printf(ftpcmds);
|
||||
system(ftpcmds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
240
mozilla/xpinstall/wizard/unix/src2/nsComponent.cpp
Normal file
240
mozilla/xpinstall/wizard/unix/src2/nsComponent.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsComponent.h"
|
||||
|
||||
nsComponent::nsComponent() :
|
||||
mDescShort(NULL),
|
||||
mDescLong(NULL),
|
||||
mArchive(NULL),
|
||||
mSize(0),
|
||||
mDependencies(NULL),
|
||||
mAttributes(NO_ATTR)
|
||||
{
|
||||
}
|
||||
|
||||
nsComponent::~nsComponent()
|
||||
{
|
||||
if (mDescShort)
|
||||
free (mDescShort);
|
||||
if (mDescLong)
|
||||
free (mDescLong);
|
||||
if (mArchive)
|
||||
free (mArchive);
|
||||
if (mDependencies)
|
||||
delete mDependencies;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetDescShort(char *aDescShort)
|
||||
{
|
||||
if (!aDescShort)
|
||||
return E_PARAM;
|
||||
|
||||
mDescShort = aDescShort;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsComponent::GetDescShort()
|
||||
{
|
||||
if (mDescShort)
|
||||
return mDescShort;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetDescLong(char *aDescLong)
|
||||
{
|
||||
if (!aDescLong)
|
||||
return E_PARAM;
|
||||
|
||||
mDescLong = aDescLong;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsComponent::GetDescLong()
|
||||
{
|
||||
if (mDescLong)
|
||||
return mDescLong;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetArchive(char *aArchive)
|
||||
{
|
||||
if (!aArchive)
|
||||
return E_PARAM;
|
||||
|
||||
mArchive = aArchive;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsComponent::GetArchive()
|
||||
{
|
||||
if (mArchive)
|
||||
return mArchive;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetSize(int aSize)
|
||||
{
|
||||
mSize = aSize;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::GetSize()
|
||||
{
|
||||
if (mSize >= 0)
|
||||
return mSize;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::AddDependency(nsComponent *aDependent)
|
||||
{
|
||||
if (!aDependent)
|
||||
return E_PARAM;
|
||||
|
||||
if (!mDependencies)
|
||||
mDependencies = new nsComponentList();
|
||||
|
||||
if (!mDependencies)
|
||||
return E_MEM;
|
||||
|
||||
return mDependencies->AddComponent(aDependent);
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::RemoveDependency(nsComponent *aIndependent)
|
||||
{
|
||||
if (!aIndependent)
|
||||
return E_PARAM;
|
||||
|
||||
if (!mDependencies)
|
||||
return E_NO_MEMBER;
|
||||
|
||||
return mDependencies->RemoveComponent(aIndependent);
|
||||
}
|
||||
|
||||
nsComponentList *
|
||||
nsComponent::GetDependencies()
|
||||
{
|
||||
if (mDependencies)
|
||||
return mDependencies;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetSelected()
|
||||
{
|
||||
mAttributes |= nsComponent::SELECTED;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetUnselected()
|
||||
{
|
||||
if (IsSelected())
|
||||
mAttributes &= ~nsComponent::SELECTED;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::IsSelected()
|
||||
{
|
||||
if (mAttributes & nsComponent::SELECTED)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetInvisible()
|
||||
{
|
||||
mAttributes |= nsComponent::INVISIBLE;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetVisible()
|
||||
{
|
||||
if (IsInvisible())
|
||||
mAttributes &= ~nsComponent::INVISIBLE;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::IsInvisible()
|
||||
{
|
||||
if (mAttributes & nsComponent::INVISIBLE)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::SetNext(nsComponent *aComponent)
|
||||
{
|
||||
if (!aComponent)
|
||||
return E_PARAM;
|
||||
|
||||
mNext = aComponent;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponent::InitNext()
|
||||
{
|
||||
mNext = NULL;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
nsComponent *
|
||||
nsComponent::GetNext()
|
||||
{
|
||||
if (mNext)
|
||||
return mNext;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
84
mozilla/xpinstall/wizard/unix/src2/nsComponent.h
Normal file
84
mozilla/xpinstall/wizard/unix/src2/nsComponent.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_COMPONENT_H_
|
||||
#define _NS_COMPONENT_H_
|
||||
|
||||
#include "XILimits.h"
|
||||
#include "XIErrors.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "nsComponentList.h"
|
||||
|
||||
class nsComponent
|
||||
{
|
||||
public:
|
||||
nsComponent();
|
||||
~nsComponent();
|
||||
|
||||
/*--------------------------------------------------------------*
|
||||
* Accessors/Mutators
|
||||
*--------------------------------------------------------------*/
|
||||
int SetDescShort(char *aDescShort);
|
||||
char * GetDescShort();
|
||||
int SetDescLong(char *aDescLong);
|
||||
char * GetDescLong();
|
||||
int SetArchive(char *aAcrhive);
|
||||
char * GetArchive();
|
||||
int SetSize(int aSize);
|
||||
int GetSize();
|
||||
int AddDependency(nsComponent *aDependent);
|
||||
int RemoveDependency(nsComponent *aIndependent);
|
||||
nsComponentList *GetDependencies();
|
||||
int SetSelected();
|
||||
int SetUnselected();
|
||||
int IsSelected();
|
||||
int SetInvisible();
|
||||
int SetVisible();
|
||||
int IsInvisible();
|
||||
int SetNext(nsComponent *aComponent);
|
||||
int InitNext();
|
||||
nsComponent *GetNext();
|
||||
|
||||
/*---------------------------------------------------------------*
|
||||
* Attributes
|
||||
*---------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
NO_ATTR = 0x00000000,
|
||||
SELECTED = 0x00000001,
|
||||
INVISIBLE = 0x00000010
|
||||
};
|
||||
|
||||
private:
|
||||
char *mDescShort;
|
||||
char *mDescLong;
|
||||
char *mArchive;
|
||||
int mSize;
|
||||
nsComponentList *mDependencies;
|
||||
int mAttributes;
|
||||
nsComponent *mNext;
|
||||
};
|
||||
|
||||
#endif /* _NS_COMPONENT_H_ */
|
||||
149
mozilla/xpinstall/wizard/unix/src2/nsComponentList.cpp
Normal file
149
mozilla/xpinstall/wizard/unix/src2/nsComponentList.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsComponentList.h"
|
||||
#include "nsComponent.h"
|
||||
|
||||
nsComponentList::nsComponentList() :
|
||||
mHead(NULL),
|
||||
mTail(NULL),
|
||||
mNext(NULL),
|
||||
mLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
nsComponentList::~nsComponentList()
|
||||
{
|
||||
nsComponent *curr = mHead;
|
||||
nsComponent *next = NULL;
|
||||
|
||||
while (curr)
|
||||
{
|
||||
next = NULL;
|
||||
next = curr->GetNext();
|
||||
delete curr;
|
||||
curr = next;
|
||||
}
|
||||
|
||||
mHead = NULL;
|
||||
mTail = NULL;
|
||||
mLength = 0;
|
||||
}
|
||||
|
||||
nsComponent *
|
||||
nsComponentList::GetHead()
|
||||
{
|
||||
if (mHead)
|
||||
{
|
||||
mNext = mHead->GetNext();
|
||||
return mHead;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsComponent *
|
||||
nsComponentList::GetNext()
|
||||
{
|
||||
nsComponent *curr = mNext;
|
||||
|
||||
if (mNext)
|
||||
{
|
||||
mNext = mNext->GetNext();
|
||||
return curr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsComponent *
|
||||
nsComponentList::GetTail()
|
||||
{
|
||||
if (mTail)
|
||||
return mTail;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponentList::AddComponent(nsComponent *aComponent)
|
||||
{
|
||||
if (!aComponent)
|
||||
return E_PARAM;
|
||||
|
||||
// empty list: head and tail are the same -- the new comp
|
||||
if (!mHead)
|
||||
{
|
||||
mHead = aComponent;
|
||||
mHead->InitNext();
|
||||
mTail = mHead;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
// non-empty list: the new comp is tacked on and tail is updated
|
||||
mTail->SetNext(aComponent);
|
||||
mTail = aComponent;
|
||||
mTail->InitNext();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponentList::RemoveComponent(nsComponent *aComponent)
|
||||
{
|
||||
nsComponent *curr = GetHead();
|
||||
nsComponent *last = NULL;
|
||||
|
||||
if (!aComponent)
|
||||
return E_PARAM;
|
||||
|
||||
while (curr)
|
||||
{
|
||||
if (aComponent == curr)
|
||||
{
|
||||
// remove and link last to next while deleting current
|
||||
if (last)
|
||||
{
|
||||
last->SetNext(curr->GetNext());
|
||||
}
|
||||
else
|
||||
{
|
||||
mHead = curr->GetNext();
|
||||
if (mTail == curr)
|
||||
mTail = NULL;
|
||||
}
|
||||
|
||||
delete aComponent;
|
||||
|
||||
return OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
// move on to next
|
||||
last = curr;
|
||||
curr = GetNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
96
mozilla/xpinstall/wizard/unix/src2/nsComponentList.h
Normal file
96
mozilla/xpinstall/wizard/unix/src2/nsComponentList.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_COMPONENTLIST_H_
|
||||
#define _NS_COMPONENTLIST_H_
|
||||
|
||||
#include "XIErrors.h"
|
||||
|
||||
class nsComponent;
|
||||
|
||||
class nsComponentList
|
||||
{
|
||||
public:
|
||||
nsComponentList();
|
||||
~nsComponentList();
|
||||
|
||||
/**
|
||||
* GetHead
|
||||
*
|
||||
* Initializes the next ptr to the second item and
|
||||
* returns the head item.
|
||||
*
|
||||
* @return mHead the head of the singly-linked list
|
||||
*/
|
||||
nsComponent * GetHead();
|
||||
|
||||
/**
|
||||
* GetNext
|
||||
*
|
||||
* Returns the next available item. GetFirst() has to have
|
||||
* been called prior calling this and after the last time
|
||||
* the entire list was iterated over.
|
||||
*
|
||||
* @return mNext the next available component
|
||||
*/
|
||||
nsComponent * GetNext();
|
||||
|
||||
/**
|
||||
* GetTail
|
||||
*
|
||||
* Returns the tail item of the list.
|
||||
*
|
||||
* @return mTail the tail item of the list
|
||||
*/
|
||||
nsComponent * GetTail();
|
||||
|
||||
/**
|
||||
* AddComponent
|
||||
*
|
||||
* Adds the supplied component to the list's tail.
|
||||
*
|
||||
* @param aComponent the component to add
|
||||
* @return err integer err code (zero means OK)
|
||||
*/
|
||||
int AddComponent(nsComponent *aComponent);
|
||||
|
||||
/**
|
||||
* RemoveComponent
|
||||
*
|
||||
* Searches the list and removes the first component that
|
||||
* matches the supplied component.
|
||||
*
|
||||
* @param aComponent the component to remove
|
||||
* @return err integer error code (zero means OK)
|
||||
*/
|
||||
int RemoveComponent(nsComponent *aComponent);
|
||||
|
||||
private:
|
||||
nsComponent *mHead;
|
||||
nsComponent *mTail;
|
||||
nsComponent *mNext;
|
||||
int mLength;
|
||||
};
|
||||
|
||||
#endif /* _NS_COMPONENTLIST_H_ */
|
||||
92
mozilla/xpinstall/wizard/unix/src2/nsComponentsDlg.cpp
Normal file
92
mozilla/xpinstall/wizard/unix/src2/nsComponentsDlg.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsComponentsDlg.h"
|
||||
|
||||
nsComponentsDlg::nsComponentsDlg() :
|
||||
mMsg0(NULL),
|
||||
mCompList(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsComponentsDlg::~nsComponentsDlg()
|
||||
{
|
||||
if (mMsg0)
|
||||
free (mMsg0);
|
||||
|
||||
if (mCompList)
|
||||
delete mCompList;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponentsDlg::Back()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponentsDlg::Next()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponentsDlg::SetMsg0(char *aMsg)
|
||||
{
|
||||
if (!aMsg)
|
||||
return E_PARAM;
|
||||
|
||||
mMsg0 = aMsg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsComponentsDlg::GetMsg0()
|
||||
{
|
||||
if (mMsg0)
|
||||
return mMsg0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsComponentsDlg::SetCompList(nsComponentList *aCompList)
|
||||
{
|
||||
if (!aCompList)
|
||||
return E_PARAM;
|
||||
|
||||
mCompList = aCompList;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
nsComponentList *
|
||||
nsComponentsDlg::GetCompList()
|
||||
{
|
||||
if (mCompList)
|
||||
return mCompList;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
59
mozilla/xpinstall/wizard/unix/src2/nsComponentsDlg.h
Normal file
59
mozilla/xpinstall/wizard/unix/src2/nsComponentsDlg.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_COMPONENTSDLG_H_
|
||||
#define _NS_COMPONENTSDLG_H_
|
||||
|
||||
#include "XIErrors.h"
|
||||
|
||||
#include "nsXInstallerDlg.h"
|
||||
#include "nsComponentList.h"
|
||||
|
||||
class nsComponentsDlg : public nsXInstallerDlg
|
||||
{
|
||||
public:
|
||||
nsComponentsDlg();
|
||||
~nsComponentsDlg();
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* Navigation
|
||||
*--------------------------------------------------------------------*/
|
||||
int Back();
|
||||
int Next();
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* INI Properties
|
||||
*--------------------------------------------------------------------*/
|
||||
int SetMsg0(char *aMsg);
|
||||
char *GetMsg0();
|
||||
|
||||
int SetCompList(nsComponentList *aCompList);
|
||||
nsComponentList *GetCompList();
|
||||
|
||||
private:
|
||||
char *mMsg0;
|
||||
nsComponentList *mCompList;
|
||||
};
|
||||
|
||||
#endif /* _NS_COMPONENTSDLG_H_ */
|
||||
265
mozilla/xpinstall/wizard/unix/src2/nsINIParser.cpp
Normal file
265
mozilla/xpinstall/wizard/unix/src2/nsINIParser.cpp
Normal file
@@ -0,0 +1,265 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "nsINIParser.h"
|
||||
|
||||
nsINIParser::nsINIParser(char *aFilename)
|
||||
{
|
||||
FILE *fd = NULL;
|
||||
fpos_t eofpos = (fpos_t) NULL;
|
||||
int rd = 0;
|
||||
|
||||
mFileBuf = NULL;
|
||||
mFileBufSize = 0;
|
||||
mError = OK;
|
||||
DUMP("nsINIParser");
|
||||
|
||||
/* param check */
|
||||
if (!aFilename)
|
||||
{
|
||||
mError = E_PARAM;
|
||||
return;
|
||||
}
|
||||
|
||||
/* open the file */
|
||||
fd = fopen(aFilename, "r");
|
||||
if (!fd)
|
||||
goto bail;
|
||||
|
||||
/* get file size */
|
||||
if (fseek(fd, 0, SEEK_END) != 0)
|
||||
goto bail;
|
||||
if (fgetpos(fd, &eofpos) != 0)
|
||||
goto bail;
|
||||
|
||||
/* malloc an internal buf the size of the file */
|
||||
mFileBuf = (char *) malloc(eofpos * sizeof(char));
|
||||
if (!mFileBuf)
|
||||
{
|
||||
mError = E_MEM;
|
||||
return;
|
||||
}
|
||||
mFileBufSize = eofpos;
|
||||
|
||||
/* read the file in one swoop */
|
||||
if (fseek(fd, 0, SEEK_SET) != 0)
|
||||
goto bail;
|
||||
rd = fread((void *)mFileBuf, 1, eofpos, fd);
|
||||
if (!rd)
|
||||
goto bail;
|
||||
|
||||
/* close file */
|
||||
fclose(fd);
|
||||
|
||||
return;
|
||||
|
||||
bail:
|
||||
mError = E_READ;
|
||||
return;
|
||||
}
|
||||
|
||||
nsINIParser::~nsINIParser()
|
||||
{
|
||||
DUMP("~nsINIParser");
|
||||
}
|
||||
|
||||
int
|
||||
nsINIParser::GetString( char *aSection, char *aKey,
|
||||
char *aValBuf, int *aIOValBufSize )
|
||||
{
|
||||
char *secPtr = NULL;
|
||||
mError = OK;
|
||||
DUMP("GetString");
|
||||
|
||||
/* param check */
|
||||
if ( !aSection || !aKey || !aValBuf ||
|
||||
!aIOValBufSize || (*aIOValBufSize <= 0) )
|
||||
return E_PARAM;
|
||||
|
||||
/* find the section if it exists */
|
||||
mError = FindSection(aSection, &secPtr);
|
||||
if (mError != OK)
|
||||
return mError;
|
||||
|
||||
/* find the key if it exists in the valid section we found */
|
||||
mError = FindKey(secPtr, aKey, aValBuf, aIOValBufSize);
|
||||
|
||||
return mError;
|
||||
}
|
||||
|
||||
int
|
||||
nsINIParser::GetStringAlloc( char *aSection, char *aKey,
|
||||
char **aOutBuf, int *aOutBufSize )
|
||||
{
|
||||
char buf[MAX_VAL_SIZE];
|
||||
int bufsize = MAX_VAL_SIZE;
|
||||
mError = OK;
|
||||
DUMP("GetStringAlloc");
|
||||
|
||||
mError = GetString(aSection, aKey, buf, &bufsize);
|
||||
if (mError != OK)
|
||||
return mError;
|
||||
|
||||
*aOutBuf = (char *) malloc(bufsize + 1);
|
||||
strncpy(*aOutBuf, buf, bufsize);
|
||||
strcat(*aOutBuf, "\0");
|
||||
*aOutBufSize = bufsize + 1;
|
||||
|
||||
return mError;
|
||||
}
|
||||
|
||||
int
|
||||
nsINIParser::GetError()
|
||||
{
|
||||
DUMP("GetError");
|
||||
return mError;
|
||||
}
|
||||
|
||||
int
|
||||
nsINIParser::FindSection(char *aSection, char **aOutSecPtr)
|
||||
{
|
||||
char *currChar = mFileBuf;
|
||||
char *nextSec = NULL;
|
||||
char *secClose = NULL;
|
||||
char *nextNL = NULL;
|
||||
mError = E_NO_SEC;
|
||||
DUMP("FindSection");
|
||||
|
||||
// param check
|
||||
if (!aSection || !aOutSecPtr)
|
||||
{
|
||||
mError = E_PARAM;
|
||||
return mError;
|
||||
}
|
||||
|
||||
while (currChar < (mFileBuf + mFileBufSize))
|
||||
{
|
||||
// look for first '['
|
||||
nextSec = NULL;
|
||||
nextSec = strchr(currChar, '[');
|
||||
if (!nextSec)
|
||||
break;
|
||||
|
||||
currChar = nextSec + 1;
|
||||
|
||||
// extract section name till first ']'
|
||||
secClose = NULL; nextNL = NULL;
|
||||
secClose = strchr(currChar, ']');
|
||||
nextNL = strchr(currChar, NL);
|
||||
if ((!nextNL) || (nextNL < secClose))
|
||||
{
|
||||
currChar = nextNL;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if section name matches we succeeded
|
||||
if (strncmp(aSection, currChar, secClose - currChar) == 0)
|
||||
{
|
||||
*aOutSecPtr = secClose + 1;
|
||||
mError = OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return mError;
|
||||
}
|
||||
|
||||
int
|
||||
nsINIParser::FindKey(char *aSecPtr, char *aKey, char *aVal, int *aIOValSize)
|
||||
{
|
||||
char *nextNL = NULL;
|
||||
char *secEnd = NULL;
|
||||
char *currLine = aSecPtr;
|
||||
char *nextEq = NULL;
|
||||
mError = E_NO_KEY;
|
||||
DUMP("FindKey");
|
||||
|
||||
// param check
|
||||
if (!aSecPtr || !aKey || !aVal || !aIOValSize || (*aIOValSize <= 0))
|
||||
{
|
||||
mError = E_PARAM;
|
||||
return mError;
|
||||
}
|
||||
|
||||
// determine the section end
|
||||
secEnd = strchr(aSecPtr, '['); // search for next sec start
|
||||
if (!secEnd)
|
||||
{
|
||||
secEnd = strchr(aSecPtr, '\0'); // else search for file end
|
||||
if (!secEnd)
|
||||
{
|
||||
mError = E_SEC_CORRUPT; // else this data is corrupt
|
||||
return mError;
|
||||
}
|
||||
}
|
||||
|
||||
while (currLine < secEnd)
|
||||
{
|
||||
nextNL = NULL;
|
||||
nextNL = strchr(currLine, NL);
|
||||
if (!nextNL)
|
||||
nextNL = mFileBuf + mFileBufSize;
|
||||
|
||||
// ignore commented lines (starting with ;)
|
||||
if (currLine == strchr(currLine, ';'))
|
||||
{
|
||||
currLine = nextNL + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// extract key before '='
|
||||
nextEq = NULL;
|
||||
nextEq = strchr(currLine, '=');
|
||||
if (!nextEq || nextEq > nextNL)
|
||||
{
|
||||
currLine = nextNL + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if key matches we succeeded
|
||||
if (strncmp(currLine, aKey, nextEq - currLine) == 0)
|
||||
{
|
||||
// extract the value and return
|
||||
if (*aIOValSize < nextNL - nextEq)
|
||||
{
|
||||
mError = E_SMALL_BUF;
|
||||
*aVal = "\0";
|
||||
*aIOValSize = 0;
|
||||
return mError;
|
||||
}
|
||||
|
||||
*aIOValSize = nextNL - nextEq;
|
||||
strncpy(aVal, (nextEq + 1), *aIOValSize);
|
||||
mError = OK;
|
||||
return mError;
|
||||
}
|
||||
else
|
||||
{
|
||||
currLine = nextNL + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return mError;
|
||||
}
|
||||
128
mozilla/xpinstall/wizard/unix/src2/nsINIParser.h
Normal file
128
mozilla/xpinstall/wizard/unix/src2/nsINIParser.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_INIPARSER_H_
|
||||
#define _NS_INIPARSER_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
class nsINIParser
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* nsINIParser
|
||||
*
|
||||
* Construct a new INI parser for the file specified.
|
||||
*
|
||||
* @param aFilename path to INI file
|
||||
*/
|
||||
nsINIParser(char *aFilename);
|
||||
~nsINIParser();
|
||||
|
||||
/**
|
||||
* GetString
|
||||
*
|
||||
* Gets the value of the specified key in the specified section
|
||||
* of the INI file represented by this instance. The value is stored
|
||||
* in the supplied buffer. The buffer size is provided as input and
|
||||
* the actual bytes used by the value is set in the in/out size param.
|
||||
*
|
||||
* @param aSection section name
|
||||
* @param aKey key name
|
||||
* @param aValBuf user supplied buffer
|
||||
* @param aIOValBufSize buf size on input; actual buf used on output
|
||||
*
|
||||
* @return mError operation success code
|
||||
*/
|
||||
int GetString( char *aSection, char *aKey,
|
||||
char *aValBuf, int *aIOValBufSize );
|
||||
|
||||
/**
|
||||
* GetStringAlloc
|
||||
*
|
||||
* Same as GetString() except the buffer is allocated to the exact
|
||||
* size of the value. Useful when the buffer is allocated everytime
|
||||
* rather than reusing the same buffer when calling this function
|
||||
* multiple times.
|
||||
*
|
||||
* @param aSection section name
|
||||
* @param aKey key name
|
||||
* @param aOutBuf buffer to be allocated
|
||||
* @param aOutBufSize size of newly allocated buffer
|
||||
*
|
||||
* @return mError operation success code
|
||||
*/
|
||||
int GetStringAlloc( char *aSection, char *aKey,
|
||||
char **aOutBuf, int *aOutBufSize );
|
||||
|
||||
/**
|
||||
* GetError
|
||||
*
|
||||
* Exposes the last error on this instance. Useful for checking
|
||||
* teh state of the object after construtcion since the INI file
|
||||
* is parsed once at object-allocation time.
|
||||
*
|
||||
* @return mError last error on ops on this object
|
||||
*/
|
||||
int GetError();
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* Errors
|
||||
*--------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
OK = 0,
|
||||
E_READ = -701,
|
||||
E_MEM = -702,
|
||||
E_PARAM = -703,
|
||||
E_NO_SEC = -704,
|
||||
E_NO_KEY = -705,
|
||||
E_SEC_CORRUPT = -706,
|
||||
E_SMALL_BUF = -707
|
||||
};
|
||||
|
||||
private:
|
||||
int FindSection(char *aSection, char **aOutSecPtr);
|
||||
int FindKey(char *aSecPtr, char *aKey, char *aVal, int *aIOValSize);
|
||||
|
||||
char *mFileBuf;
|
||||
int mFileBufSize;
|
||||
int mError;
|
||||
};
|
||||
|
||||
#define NL '\n'
|
||||
#define MAX_VAL_SIZE 512
|
||||
|
||||
#ifdef DEBUG_druidd
|
||||
#define DUMP(_msg) printf("%s %d: %s \n", __FILE__, __LINE__, _msg);
|
||||
#else
|
||||
#define DUMP(_msg)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*_NS_INIPARSER_H_ */
|
||||
68
mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.cpp
Normal file
68
mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsInstallDlg.h"
|
||||
|
||||
nsInstallDlg::nsInstallDlg() :
|
||||
mMsg0(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsInstallDlg::~nsInstallDlg()
|
||||
{
|
||||
if (mMsg0)
|
||||
free (mMsg0);
|
||||
}
|
||||
|
||||
int
|
||||
nsInstallDlg::Back()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsInstallDlg::Next()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsInstallDlg::SetMsg0(char *aMsg)
|
||||
{
|
||||
if (!aMsg)
|
||||
return E_PARAM;
|
||||
|
||||
mMsg0 = aMsg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsInstallDlg::GetMsg0()
|
||||
{
|
||||
if (mMsg0)
|
||||
return mMsg0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
53
mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.h
Normal file
53
mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_INSTALLDLG_H_
|
||||
#define _NS_INSTALLDLG_H_
|
||||
|
||||
#include "nsXInstallerDlg.h"
|
||||
#include "XIErrors.h"
|
||||
|
||||
class nsInstallDlg : public nsXInstallerDlg
|
||||
{
|
||||
public:
|
||||
nsInstallDlg();
|
||||
~nsInstallDlg();
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
* Navigation
|
||||
*------------------------------------------------------------------*/
|
||||
int Back();
|
||||
int Next();
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
* INI Properties
|
||||
*------------------------------------------------------------------*/
|
||||
int SetMsg0(char *aMsg);
|
||||
char *GetMsg0();
|
||||
|
||||
private:
|
||||
char *mMsg0;
|
||||
};
|
||||
|
||||
#endif /* _NS_INSTALLDLG_H_ */
|
||||
114
mozilla/xpinstall/wizard/unix/src2/nsLicenseDlg.cpp
Normal file
114
mozilla/xpinstall/wizard/unix/src2/nsLicenseDlg.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsLicenseDlg.h"
|
||||
|
||||
nsLicenseDlg::nsLicenseDlg() :
|
||||
mLicenseFile(NULL),
|
||||
mMsg0(NULL),
|
||||
mMsg1(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsLicenseDlg::~nsLicenseDlg()
|
||||
{
|
||||
if (mLicenseFile)
|
||||
free (mLicenseFile);
|
||||
if (mMsg0)
|
||||
free (mMsg0);
|
||||
if (mMsg1)
|
||||
free (mMsg1);
|
||||
}
|
||||
|
||||
int
|
||||
nsLicenseDlg::Back()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsLicenseDlg::Next()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsLicenseDlg::SetLicenseFile(char *aLicenseFile)
|
||||
{
|
||||
if (!aLicenseFile)
|
||||
return E_PARAM;
|
||||
|
||||
aLicenseFile = mLicenseFile;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsLicenseDlg::GetLicenseFile()
|
||||
{
|
||||
if (mLicenseFile)
|
||||
return mLicenseFile;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsLicenseDlg::SetMsg0(char *aMsg)
|
||||
{
|
||||
if (!aMsg)
|
||||
return E_PARAM;
|
||||
|
||||
mMsg0 = aMsg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsLicenseDlg::GetMsg0()
|
||||
{
|
||||
if (mMsg0)
|
||||
return mMsg0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsLicenseDlg::SetMsg1(char *aMsg)
|
||||
{
|
||||
if (!aMsg)
|
||||
return E_PARAM;
|
||||
|
||||
mMsg1 = aMsg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsLicenseDlg::GetMsg1()
|
||||
{
|
||||
if (mMsg1)
|
||||
return mMsg1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
59
mozilla/xpinstall/wizard/unix/src2/nsLicenseDlg.h
Normal file
59
mozilla/xpinstall/wizard/unix/src2/nsLicenseDlg.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_LICENSEDLG_H_
|
||||
#define _NS_LICENSEDLG_H_
|
||||
|
||||
#include "nsXInstallerDlg.h"
|
||||
#include "XIErrors.h"
|
||||
|
||||
class nsLicenseDlg : public nsXInstallerDlg
|
||||
{
|
||||
public:
|
||||
nsLicenseDlg();
|
||||
~nsLicenseDlg();
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* Navigation
|
||||
*-------------------------------------------------------------------*/
|
||||
int Back();
|
||||
int Next();
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* INI Properties
|
||||
*-------------------------------------------------------------------*/
|
||||
int SetLicenseFile(char *aLicenseFile);
|
||||
char * GetLicenseFile();
|
||||
int SetMsg0(char *aMsg);
|
||||
char * GetMsg0();
|
||||
int SetMsg1(char *aMsg);
|
||||
char * GetMsg1();
|
||||
|
||||
private:
|
||||
char *mLicenseFile;
|
||||
char *mMsg0;
|
||||
char *mMsg1;
|
||||
};
|
||||
|
||||
#endif /* _NS_LICENSEDLG_H_ */
|
||||
139
mozilla/xpinstall/wizard/unix/src2/nsSetupType.cpp
Normal file
139
mozilla/xpinstall/wizard/unix/src2/nsSetupType.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsSetupType.h"
|
||||
|
||||
nsSetupType::nsSetupType() :
|
||||
mDescShort(NULL),
|
||||
mDescLong(NULL),
|
||||
mComponents(NULL),
|
||||
mNext(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsSetupType::~nsSetupType()
|
||||
{
|
||||
if (mDescShort)
|
||||
free (mDescShort);
|
||||
if (mDescLong)
|
||||
free (mDescLong);
|
||||
if (mComponents)
|
||||
delete mComponents;
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupType::SetDescShort(char *aDescShort)
|
||||
{
|
||||
if (!aDescShort)
|
||||
return E_PARAM;
|
||||
|
||||
mDescShort = aDescShort;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsSetupType::GetDescShort()
|
||||
{
|
||||
if (mDescShort)
|
||||
return mDescShort;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupType::SetDescLong(char *aDescLong)
|
||||
{
|
||||
if (!aDescLong)
|
||||
return E_PARAM;
|
||||
|
||||
mDescLong = aDescLong;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsSetupType::GetDescLong()
|
||||
{
|
||||
if (mDescLong)
|
||||
return mDescLong;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupType::SetComponent(nsComponent *aComponent)
|
||||
{
|
||||
if (!aComponent)
|
||||
return E_PARAM;
|
||||
|
||||
if (!mComponents)
|
||||
mComponents = new nsComponentList();
|
||||
|
||||
if (!mComponents)
|
||||
return E_MEM;
|
||||
|
||||
return mComponents->AddComponent(aComponent);
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupType::UnsetComponent(nsComponent *aComponent)
|
||||
{
|
||||
if (!aComponent)
|
||||
return E_PARAM;
|
||||
|
||||
if (!mComponents)
|
||||
return OK;
|
||||
|
||||
return mComponents->RemoveComponent(aComponent);
|
||||
}
|
||||
|
||||
nsComponentList *
|
||||
nsSetupType::GetComponents()
|
||||
{
|
||||
if (mComponents)
|
||||
return mComponents;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupType::SetNext(nsSetupType *aSetupType)
|
||||
{
|
||||
if (!aSetupType)
|
||||
return E_PARAM;
|
||||
|
||||
mNext = aSetupType;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
nsSetupType *
|
||||
nsSetupType::GetNext()
|
||||
{
|
||||
if (mNext)
|
||||
return mNext;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
61
mozilla/xpinstall/wizard/unix/src2/nsSetupType.h
Normal file
61
mozilla/xpinstall/wizard/unix/src2/nsSetupType.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_SETUPTYPE_H_
|
||||
#define _NS_SETUPTYPE_H_
|
||||
|
||||
#include "XILimits.h"
|
||||
#include "XIErrors.h"
|
||||
|
||||
#include "nsComponent.h"
|
||||
|
||||
class nsComponentList;
|
||||
|
||||
class nsSetupType
|
||||
{
|
||||
public:
|
||||
nsSetupType();
|
||||
~nsSetupType();
|
||||
|
||||
/*--------------------------------------------------------------*
|
||||
* Accessors/Mutators
|
||||
*--------------------------------------------------------------*/
|
||||
int SetDescShort(char *aDescShort);
|
||||
char * GetDescShort();
|
||||
int SetDescLong(char *aDescLong);
|
||||
char * GetDescLong();
|
||||
int SetComponent(nsComponent *aComponent);
|
||||
int UnsetComponent(nsComponent *aComponent);
|
||||
nsComponentList *GetComponents();
|
||||
int SetNext(nsSetupType *aSetupType);
|
||||
nsSetupType * GetNext();
|
||||
|
||||
private:
|
||||
char *mDescShort;
|
||||
char *mDescLong;
|
||||
nsComponentList *mComponents;
|
||||
nsSetupType *mNext;
|
||||
};
|
||||
|
||||
#endif /* _NS_SETUPTYPE_H_ */
|
||||
103
mozilla/xpinstall/wizard/unix/src2/nsSetupTypeDlg.cpp
Normal file
103
mozilla/xpinstall/wizard/unix/src2/nsSetupTypeDlg.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
#include "nsSetupTypeDlg.h"
|
||||
|
||||
nsSetupTypeDlg::nsSetupTypeDlg() :
|
||||
mMsg0(NULL),
|
||||
mSetupTypeList(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsSetupTypeDlg::~nsSetupTypeDlg()
|
||||
{
|
||||
FreeSetupTypeList();
|
||||
|
||||
if (mMsg0)
|
||||
free (mMsg0);
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupTypeDlg::Back()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupTypeDlg::Next()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupTypeDlg::SetMsg0(char *aMsg)
|
||||
{
|
||||
if (!aMsg)
|
||||
return E_PARAM;
|
||||
|
||||
mMsg0 = aMsg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsSetupTypeDlg::GetMsg0()
|
||||
{
|
||||
if (mMsg0)
|
||||
return mMsg0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsSetupTypeDlg::AddSetupType(nsSetupType *aSetupType)
|
||||
{
|
||||
if (!aSetupType)
|
||||
return E_PARAM;
|
||||
|
||||
if (!mSetupTypeList)
|
||||
{
|
||||
mSetupTypeList = aSetupType;
|
||||
return OK;
|
||||
}
|
||||
|
||||
nsSetupType *curr = mSetupTypeList;
|
||||
nsSetupType *next;
|
||||
while (curr)
|
||||
{
|
||||
next = NULL;
|
||||
next = curr->GetNext();
|
||||
|
||||
if (!next)
|
||||
{
|
||||
return curr->SetNext(aSetupType);
|
||||
}
|
||||
|
||||
curr = next;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
nsSetupType *
|
||||
nsSetupTypeDlg::GetSetupTypeList()
|
||||
{
|
||||
if (mSetupTypeList)
|
||||
return mSetupTypeList;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
nsSetupTypeDlg::FreeSetupTypeList()
|
||||
{
|
||||
nsSetupType *curr = mSetupTypeList;
|
||||
nsSetupType *prev;
|
||||
|
||||
while (curr)
|
||||
{
|
||||
prev = curr;
|
||||
curr = curr->GetNext();
|
||||
|
||||
if (prev)
|
||||
delete prev;
|
||||
}
|
||||
}
|
||||
59
mozilla/xpinstall/wizard/unix/src2/nsSetupTypeDlg.h
Normal file
59
mozilla/xpinstall/wizard/unix/src2/nsSetupTypeDlg.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_SETUPTYPEDLG_H_
|
||||
#define _NS_SETUPTYPEDLG_H_
|
||||
|
||||
#include "nsXInstallerDlg.h"
|
||||
#include "nsSetupType.h"
|
||||
|
||||
class nsSetupTypeDlg : public nsXInstallerDlg
|
||||
{
|
||||
public:
|
||||
nsSetupTypeDlg();
|
||||
~nsSetupTypeDlg();
|
||||
|
||||
/*---------------------------------------------------------------------*
|
||||
* Navigation
|
||||
*---------------------------------------------------------------------*/
|
||||
int Back();
|
||||
int Next();
|
||||
|
||||
/*---------------------------------------------------------------------*
|
||||
* INI Properties
|
||||
*---------------------------------------------------------------------*/
|
||||
int SetMsg0(char *aMsg);
|
||||
char *GetMsg0();
|
||||
|
||||
int AddSetupType(nsSetupType *aSetupType);
|
||||
nsSetupType *GetSetupTypeList();
|
||||
|
||||
private:
|
||||
void FreeSetupTypeList();
|
||||
|
||||
char *mMsg0;
|
||||
nsSetupType *mSetupTypeList;
|
||||
};
|
||||
|
||||
#endif /* _NS_SETUPTYPEDLG_H_ */
|
||||
137
mozilla/xpinstall/wizard/unix/src2/nsWelcomeDlg.cpp
Normal file
137
mozilla/xpinstall/wizard/unix/src2/nsWelcomeDlg.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsWelcomeDlg.h"
|
||||
|
||||
nsWelcomeDlg::nsWelcomeDlg() :
|
||||
mReadmeFile(NULL),
|
||||
mMsg0(NULL),
|
||||
mMsg1(NULL),
|
||||
mMsg2(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsWelcomeDlg::~nsWelcomeDlg()
|
||||
{
|
||||
if (mReadmeFile)
|
||||
free (mReadmeFile);
|
||||
if (mMsg0)
|
||||
free (mMsg0);
|
||||
if (mMsg1)
|
||||
free (mMsg1);
|
||||
if (mMsg2)
|
||||
free (mMsg2);
|
||||
}
|
||||
|
||||
int
|
||||
nsWelcomeDlg::Back()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsWelcomeDlg::Next()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsWelcomeDlg::SetReadmeFile(char *aReadmeFile)
|
||||
{
|
||||
if (!aReadmeFile)
|
||||
return E_PARAM;
|
||||
|
||||
mReadmeFile = aReadmeFile;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsWelcomeDlg::GetReadmeFile()
|
||||
{
|
||||
if (mReadmeFile)
|
||||
return mReadmeFile;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsWelcomeDlg::SetMsg0(char *aMsg)
|
||||
{
|
||||
if (!aMsg)
|
||||
return E_PARAM;
|
||||
|
||||
mMsg0 = aMsg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsWelcomeDlg::GetMsg0()
|
||||
{
|
||||
if (mMsg0)
|
||||
return mMsg0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsWelcomeDlg::SetMsg1(char *aMsg)
|
||||
{
|
||||
if (!aMsg)
|
||||
return E_PARAM;
|
||||
|
||||
mMsg1 = aMsg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsWelcomeDlg::GetMsg1()
|
||||
{
|
||||
if (mMsg1)
|
||||
return mMsg1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nsWelcomeDlg::SetMsg2(char *aMsg)
|
||||
{
|
||||
if (!aMsg)
|
||||
return E_PARAM;
|
||||
|
||||
mMsg2 = aMsg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsWelcomeDlg::GetMsg2()
|
||||
{
|
||||
if (mMsg2)
|
||||
return mMsg2;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
62
mozilla/xpinstall/wizard/unix/src2/nsWelcomeDlg.h
Normal file
62
mozilla/xpinstall/wizard/unix/src2/nsWelcomeDlg.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_WELCOMEDLG_H_
|
||||
#define _NS_WELCOMEDLG_H_
|
||||
|
||||
#include "nsXInstallerDlg.h"
|
||||
#include "XIErrors.h"
|
||||
|
||||
class nsWelcomeDlg : public nsXInstallerDlg
|
||||
{
|
||||
public:
|
||||
nsWelcomeDlg();
|
||||
~nsWelcomeDlg();
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* Navigation
|
||||
*--------------------------------------------------------------------*/
|
||||
int Back();
|
||||
int Next();
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
* INI Properties
|
||||
*--------------------------------------------------------------------*/
|
||||
int SetReadmeFile(char *aReadmeFile);
|
||||
char *GetReadmeFile();
|
||||
int SetMsg0(char *aMsg);
|
||||
char *GetMsg0();
|
||||
int SetMsg1(char *aMsg);
|
||||
char *GetMsg1();
|
||||
int SetMsg2(char *aMsg);
|
||||
char *GetMsg2();
|
||||
|
||||
private:
|
||||
char *mReadmeFile;
|
||||
char *mMsg0;
|
||||
char *mMsg1;
|
||||
char *mMsg2;
|
||||
};
|
||||
|
||||
#endif /* _NS_WELCOMEDLG_H_ */
|
||||
126
mozilla/xpinstall/wizard/unix/src2/nsXInstaller.cpp
Normal file
126
mozilla/xpinstall/wizard/unix/src2/nsXInstaller.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "nsXInstaller.h"
|
||||
#include "nsINIParser.h"
|
||||
|
||||
#include "XIErrors.h"
|
||||
|
||||
nsXInstaller::nsXInstaller()
|
||||
{
|
||||
}
|
||||
|
||||
nsXInstaller::~nsXInstaller()
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstaller::ParseConfig()
|
||||
{
|
||||
int err = OK;
|
||||
nsINIParser *parser = new nsINIParser( CONFIG_INI );
|
||||
char *bufalloc = NULL;
|
||||
char buf[512];
|
||||
int bufsize = 0;
|
||||
|
||||
if (!parser)
|
||||
return E_MEM;
|
||||
|
||||
err = parser->GetError();
|
||||
if (err != nsINIParser::OK)
|
||||
return err;
|
||||
|
||||
bufsize = 512;
|
||||
// err = parser->GetString("section2", "key2", buf, &bufsize);
|
||||
err = parser->GetStringAlloc("section2", "key2", &bufalloc, &bufsize);
|
||||
if ( (err == nsINIParser::OK) && (bufalloc) && (bufsize > 0) )
|
||||
{
|
||||
DUMP("section2 key2 = ");
|
||||
DUMP(bufalloc);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstaller::Run()
|
||||
{
|
||||
int err = OK;
|
||||
|
||||
if ( (err = StartWizard()) != OK)
|
||||
goto au_revoir;
|
||||
|
||||
if ( (err = Download()) != OK)
|
||||
goto au_revoir;
|
||||
|
||||
if ( (err = Extract()) != OK)
|
||||
goto au_revoir;
|
||||
|
||||
if ( (err = Install()) != OK)
|
||||
goto au_revoir;
|
||||
|
||||
au_revoir:
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstaller::StartWizard()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstaller::Download()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstaller::Extract()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstaller::Install()
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
nsXInstaller *installer = new nsXInstaller();
|
||||
int err = OK;
|
||||
|
||||
if (installer)
|
||||
{
|
||||
if ( (err = installer->ParseConfig()) == OK)
|
||||
err = installer->Run();
|
||||
}
|
||||
|
||||
exit(err);
|
||||
}
|
||||
|
||||
59
mozilla/xpinstall/wizard/unix/src2/nsXInstaller.h
Normal file
59
mozilla/xpinstall/wizard/unix/src2/nsXInstaller.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_XINSTALLER_H_
|
||||
#define _NS_XINSTALLER_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include "XIErrors.h"
|
||||
|
||||
class nsXInstaller
|
||||
{
|
||||
public:
|
||||
nsXInstaller();
|
||||
~nsXInstaller();
|
||||
|
||||
int ParseConfig();
|
||||
int Run();
|
||||
|
||||
private:
|
||||
int StartWizard();
|
||||
int Download();
|
||||
int Extract();
|
||||
int Install();
|
||||
};
|
||||
|
||||
int main(int argc, char **argv);
|
||||
|
||||
|
||||
#define CONFIG_INI "config.ini"
|
||||
|
||||
#ifdef DEBUG_druidd
|
||||
#define DUMP(_msg) printf("%s %d: %s \n", __FILE__, __LINE__, _msg);
|
||||
#else
|
||||
#define DUMP(_msg)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*_NS_XINSTALLER_H_ */
|
||||
75
mozilla/xpinstall/wizard/unix/src2/nsXInstallerDlg.cpp
Normal file
75
mozilla/xpinstall/wizard/unix/src2/nsXInstallerDlg.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsXInstallerDlg.h"
|
||||
|
||||
nsXInstallerDlg::nsXInstallerDlg() :
|
||||
mShowDlg(nsXInstallerDlg::SHOW_DLG),
|
||||
mTitle(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nsXInstallerDlg::~nsXInstallerDlg()
|
||||
{
|
||||
if (mTitle)
|
||||
free (mTitle);
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstallerDlg::SetShowDlg(int aShowDlg)
|
||||
{
|
||||
if ( aShowDlg != nsXInstallerDlg::SHOW_DLG &&
|
||||
aShowDlg != nsXInstallerDlg::SKIP_DLG )
|
||||
return E_PARAM;
|
||||
|
||||
mShowDlg = aShowDlg;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstallerDlg::GetShowDlg()
|
||||
{
|
||||
return mShowDlg;
|
||||
}
|
||||
|
||||
int
|
||||
nsXInstallerDlg::SetTitle(char *aTitle)
|
||||
{
|
||||
if (!aTitle)
|
||||
return E_PARAM;
|
||||
|
||||
mTitle = aTitle;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
char *
|
||||
nsXInstallerDlg::GetTitle()
|
||||
{
|
||||
if (mTitle)
|
||||
return mTitle;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
70
mozilla/xpinstall/wizard/unix/src2/nsXInstallerDlg.h
Normal file
70
mozilla/xpinstall/wizard/unix/src2/nsXInstallerDlg.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NS_XINSTALLERDLG_H_
|
||||
#define _NS_XINSTALLERDLG_H_
|
||||
|
||||
#include <malloc.h>
|
||||
#include "XIErrors.h"
|
||||
|
||||
/**
|
||||
* nsXInstallerDlg
|
||||
*
|
||||
* The interface for all installer dialogs. Helps maintain
|
||||
* uniform navigation mechanism and UI widgets.
|
||||
*/
|
||||
class nsXInstallerDlg
|
||||
{
|
||||
public:
|
||||
nsXInstallerDlg();
|
||||
virtual ~nsXInstallerDlg();
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* Navigation
|
||||
*-------------------------------------------------------------------*/
|
||||
virtual int Back() = 0;
|
||||
virtual int Next() = 0;
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* INI Properties
|
||||
*-------------------------------------------------------------------*/
|
||||
int SetShowDlg(int aShowDlg);
|
||||
int GetShowDlg();
|
||||
int SetTitle(char *aTitle);
|
||||
char *GetTitle();
|
||||
|
||||
// TO DO
|
||||
|
||||
enum
|
||||
{
|
||||
SKIP_DLG = 0,
|
||||
SHOW_DLG = 1
|
||||
};
|
||||
|
||||
protected:
|
||||
int mShowDlg;
|
||||
char *mTitle;
|
||||
};
|
||||
|
||||
#endif /* _NS_INSTALLERDLG_H_ */
|
||||
Reference in New Issue
Block a user