Compare commits
1 Commits
N3
...
tags/XTech
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf03213784 |
@@ -28,7 +28,7 @@ DIRS = \
|
||||
config \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_BUILD_NSPR
|
||||
ifndef MOZ_NATIVE_NSPR
|
||||
DIRS += \
|
||||
nsprpub \
|
||||
$(NULL)
|
||||
@@ -67,7 +67,6 @@ DIRS += \
|
||||
lib/libpwcac \
|
||||
network \
|
||||
htmlparser \
|
||||
expat \
|
||||
gfx \
|
||||
dom \
|
||||
view \
|
||||
@@ -80,9 +79,8 @@ DIRS += \
|
||||
sun-java \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_BUILD_XPFE
|
||||
|
||||
DIRS += xpfe
|
||||
endif
|
||||
|
||||
ifdef MOZ_MAIL_NEWS
|
||||
DIRS += mailnews
|
||||
@@ -103,3 +101,4 @@ real_install: install
|
||||
real_clobber: clobber
|
||||
|
||||
real_depend: depend
|
||||
|
||||
|
||||
@@ -17,27 +17,23 @@
|
||||
#
|
||||
|
||||
# allmakefiles.sh - List of all makefiles.
|
||||
# Appends the list of makefiles to the variable, MAKEFILES.
|
||||
# This script outputs the list to the standard output.
|
||||
# There is no need to rerun autoconf after adding makefiles.
|
||||
# You only need to run configure.
|
||||
#
|
||||
# Unused makefiles may be commented out with '#'.
|
||||
# ('#' must be the first character on the line).
|
||||
|
||||
# add_makefiles - Shell function to add makefiles to MAKEFILES
|
||||
# add_makefiles - Shell function to write non-commented lines to stdout
|
||||
add_makefiles() {
|
||||
while read line; do
|
||||
case $line in
|
||||
\#*|dnl*) ;;
|
||||
*) MAKEFILES="$MAKEFILES $line" ;;
|
||||
*) echo $line ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
if [ -z "${srcdir}" ]; then
|
||||
srcdir=.
|
||||
fi
|
||||
|
||||
add_makefiles <<END_NGMAKEFILES
|
||||
Makefile
|
||||
base/Makefile
|
||||
@@ -75,14 +71,10 @@ dom/src/jsurl/Makefile
|
||||
dom/tools/Makefile
|
||||
editor/Makefile
|
||||
editor/public/Makefile
|
||||
expat/Makefile
|
||||
expat/xmlparse/Makefile
|
||||
expat/xmltok/Makefile
|
||||
gfx/Makefile
|
||||
gfx/public/Makefile
|
||||
gfx/src/Makefile
|
||||
gfx/src/gtk/Makefile
|
||||
gfx/src/ps/Makefile
|
||||
gfx/src/motif/Makefile
|
||||
gfx/src/rhapsody/Makefile
|
||||
gfx/tests/Makefile
|
||||
@@ -127,11 +119,8 @@ js/src/Makefile
|
||||
js/src/fdlibm/Makefile
|
||||
js/src/liveconnect/Makefile
|
||||
js/src/liveconnect/classes/Makefile
|
||||
# js/src/xpcom/Makefile
|
||||
js/src/xpcom/Makefile
|
||||
js/src/xpconnect/Makefile
|
||||
js/src/xpconnect/md/Makefile
|
||||
js/src/xpconnect/md/unix/Makefile
|
||||
js/src/xpconnect/test/Makefile
|
||||
layout/Makefile
|
||||
layout/base/Makefile
|
||||
layout/base/public/Makefile
|
||||
@@ -243,12 +232,8 @@ network/protocol/sockstub/Makefile
|
||||
network/util/Makefile
|
||||
rdf/Makefile
|
||||
rdf/base/Makefile
|
||||
rdf/base/idl/Makefile
|
||||
rdf/base/public/Makefile
|
||||
rdf/base/src/Makefile
|
||||
rdf/util/Makefile
|
||||
rdf/util/public/Makefile
|
||||
rdf/util/src/Makefile
|
||||
rdf/build/Makefile
|
||||
rdf/content/Makefile
|
||||
rdf/content/public/Makefile
|
||||
@@ -300,11 +285,6 @@ xpcom/libxpt/public/Makefile
|
||||
xpcom/libxpt/src/Makefile
|
||||
xpcom/libxpt/tests/Makefile
|
||||
xpcom/libxpt/tools/Makefile
|
||||
xpcom/libxpt/xptinfo/Makefile
|
||||
xpcom/libxpt/xptinfo/public/Makefile
|
||||
xpcom/libxpt/xptinfo/src/Makefile
|
||||
xpcom/libxpt/xptinfo/tests/Makefile
|
||||
xpcom/idl/Makefile
|
||||
silentdl/Makefile
|
||||
xpfe/Makefile
|
||||
xpfe/AppCores/Makefile
|
||||
@@ -341,5 +321,54 @@ END_EDITOR_MAKEFILES
|
||||
fi
|
||||
|
||||
if [ "$MOZ_MAIL_NEWS" ]; then
|
||||
add_makefiles < ${srcdir}/mailnews/makefiles
|
||||
add_makefiles <<END_MAILNEWS_MAKEFILES
|
||||
network/protocol/certld/Makefile
|
||||
network/protocol/imap4/Makefile
|
||||
network/protocol/mailbox/Makefile
|
||||
network/protocol/nntp/Makefile
|
||||
network/protocol/pop3/Makefile
|
||||
network/protocol/smtp/Makefile
|
||||
mailnews/Makefile
|
||||
mailnews/base/Makefile
|
||||
mailnews/base/public/Makefile
|
||||
mailnews/base/src/Makefile
|
||||
mailnews/base/build/Makefile
|
||||
mailnews/base/tests/Makefile
|
||||
mailnews/db/Makefile
|
||||
mailnews/db/mdb/Makefile
|
||||
mailnews/db/mdb/public/Makefile
|
||||
mailnews/db/msgdb/Makefile
|
||||
mailnews/db/msgdb/public/Makefile
|
||||
mailnews/db/msgdb/src/Makefile
|
||||
mailnews/local/Makefile
|
||||
mailnews/local/public/Makefile
|
||||
mailnews/local/src/Makefile
|
||||
mailnews/local/tests/Makefile
|
||||
mailnews/local/tests/pop3/Makefile
|
||||
mailnews/local/tests/mailbox/Makefile
|
||||
mailnews/imap/Makefile
|
||||
mailnews/imap/public/Makefile
|
||||
mailnews/imap/src/Makefile
|
||||
mailnews/news/Makefile
|
||||
mailnews/news/public/Makefile
|
||||
mailnews/news/src/Makefile
|
||||
mailnews/news/tests/Makefile
|
||||
mailnews/mime/Makefile
|
||||
mailnews/mime/public/Makefile
|
||||
mailnews/mime/src/Makefile
|
||||
mailnews/compose/Makefile
|
||||
mailnews/compose/public/Makefile
|
||||
mailnews/compose/src/Makefile
|
||||
mailnews/compose/tests/Makefile
|
||||
mailnews/compose/tests/smtp/Makefile
|
||||
mailnews/compose/tests/compose/Makefile
|
||||
mailnews/ui/Makefile
|
||||
mailnews/ui/messenger/Makefile
|
||||
mailnews/ui/messenger/public/Makefile
|
||||
mailnews/ui/messenger/src/Makefile
|
||||
mailnews/ui/messenger/resources/Makefile
|
||||
mailnews/ui/compose/Makefile
|
||||
mailnews/ui/ab/Makefile
|
||||
mailnews/public/Makefile
|
||||
END_MAILNEWS_MAKEFILES
|
||||
fi
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -6,9 +6,7 @@ nsAutoLock.h
|
||||
nsISizeOfHandler.h
|
||||
nsFileStream.h
|
||||
nsIFileStream.h
|
||||
nsIStringStream.h
|
||||
nsFileSpec.h
|
||||
nsRepeater.h
|
||||
nsIProperties.h
|
||||
nsCaretProperties.h
|
||||
nsSpecialSystemDirectory.h
|
||||
|
||||
@@ -33,8 +33,6 @@ EXPORTS = \
|
||||
nsFileSpec.h \
|
||||
nsFileStream.h \
|
||||
nsIFileStream.h \
|
||||
nsIStringStream.h \
|
||||
nsSpecialSystemDirectory.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
@@ -29,8 +29,6 @@ EXPORTS = \
|
||||
nsFileSpec.h \
|
||||
nsFileStream.h \
|
||||
nsIFileStream.h \
|
||||
nsIStringStream.h \
|
||||
nsSpecialSystemDirectory.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
@@ -28,7 +28,7 @@ class nsCaretProperties
|
||||
nsCaretProperties();
|
||||
virtual ~nsCaretProperties() {}
|
||||
|
||||
virtual PRInt32 GetCaretWidth() { return mCaretWidth; }
|
||||
virtual PRUint32 GetCaretWidth() { return mCaretWidth; }
|
||||
virtual PRUint32 GetCaretBlinkRate() { return mBlinkRate; }
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ class nsCaretProperties
|
||||
// have value for no blinking
|
||||
|
||||
enum {
|
||||
eDefaulBlinkRate = 500, // twice a second
|
||||
eDefaultCaretWidth = 20 // 20 twips = 1 pixel
|
||||
eDefaulBlinkRate = 500, // twice a second
|
||||
eDefaultCaretWidth = 1 // one pixel wide
|
||||
};
|
||||
|
||||
|
||||
PRInt32 mCaretWidth; // caret width in twips
|
||||
PRUint32 mCaretWidth; // caret width in twips
|
||||
PRUint32 mBlinkRate; // blink rate in milliseconds
|
||||
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@ class nsIOutputStream;
|
||||
class nsIInputStream;
|
||||
class nsOutputFileStream;
|
||||
class nsInputFileStream;
|
||||
class nsOutputConsoleStream;
|
||||
class nsString;
|
||||
|
||||
//========================================================================================
|
||||
@@ -209,7 +208,7 @@ protected:
|
||||
//========================================================================================
|
||||
class NS_BASE nsFileSpec
|
||||
// This is whatever each platform really prefers to describe files as. Declared first
|
||||
// because the other two types have an embedded nsFileSpec object.
|
||||
// because the other two types have an embeded nsFileSpec object.
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
@@ -225,27 +224,19 @@ class NS_BASE nsFileSpec
|
||||
void operator = (const char* inPath);
|
||||
void operator = (const nsString& inPath)
|
||||
{
|
||||
const nsAutoCString path(inPath);
|
||||
*this = path;
|
||||
*this = nsAutoCString(inPath);
|
||||
}
|
||||
void operator = (const nsFilePath& inPath);
|
||||
void operator = (const nsFileURL& inURL);
|
||||
void operator = (const nsFileSpec& inOther);
|
||||
void operator = (const nsPersistentFileDescriptor& inOther);
|
||||
|
||||
PRBool operator ==(const nsFileSpec& inOther) const;
|
||||
PRBool operator !=(const nsFileSpec& inOther) const;
|
||||
|
||||
operator const char* () const { return GetCString(); }
|
||||
// Same as GetCString (please read the comments).
|
||||
const char* GetCString() const;
|
||||
// This is the only conversion to const char*
|
||||
#ifndef XP_MAC
|
||||
operator const char* () const { return mPath; }
|
||||
// This is the only automatic conversion to const char*
|
||||
// that is provided, and it allows the
|
||||
// path to be "passed" to legacy code. This practice
|
||||
// is VERY EVIL and should only be used to support legacy
|
||||
// code. Using it guarantees bugs on Macintosh.
|
||||
// The path is cached and freed by the nsFileSpec destructor
|
||||
// so do not delete (or free) it.
|
||||
// path to be "passed" to NSPR file routines.
|
||||
#endif
|
||||
|
||||
#ifdef XP_MAC
|
||||
// For Macintosh people, this is meant to be useful in its own right as a C++ version
|
||||
@@ -255,19 +246,12 @@ class NS_BASE nsFileSpec
|
||||
long parID,
|
||||
ConstStr255Param name);
|
||||
nsFileSpec(const FSSpec& inSpec)
|
||||
: mSpec(inSpec), mError(NS_OK), mPath(nsnull) {}
|
||||
void operator = (const FSSpec& inSpec)
|
||||
{ mSpec = inSpec; mError = NS_OK; }
|
||||
: mSpec(inSpec), mError(NS_OK) {}
|
||||
|
||||
operator FSSpec* () { return &mSpec; }
|
||||
operator const FSSpec* const () { return &mSpec; }
|
||||
operator FSSpec& () { return mSpec; }
|
||||
operator const FSSpec& () const { return mSpec; }
|
||||
|
||||
const FSSpec& GetFSSpec() const { return mSpec; }
|
||||
FSSpec& GetFSSpec() { return mSpec; }
|
||||
ConstFSSpecPtr GetFSSpecPtr() const { return &mSpec; }
|
||||
FSSpecPtr GetFSSpecPtr() { return &mSpec; }
|
||||
void MakeAliasSafe();
|
||||
// Called for the spec of an alias. Copies the alias to
|
||||
// a secret temp directory and modifies the spec to point
|
||||
@@ -281,15 +265,7 @@ class NS_BASE nsFileSpec
|
||||
#endif // end of Macintosh utility methods.
|
||||
|
||||
PRBool Valid() const { return NS_SUCCEEDED(Error()); }
|
||||
nsresult Error() const
|
||||
{
|
||||
#ifndef XP_MAC
|
||||
if (!mPath && NS_SUCCEEDED(mError))
|
||||
((nsFileSpec*)this)->mError = NS_FILE_FAILURE;
|
||||
#endif
|
||||
return mError;
|
||||
}
|
||||
PRBool Failed() const { return NS_FAILED(Error()); }
|
||||
nsresult Error() const { return mError; }
|
||||
|
||||
|
||||
friend NS_BASE nsOutputStream& operator << (
|
||||
@@ -308,8 +284,7 @@ class NS_BASE nsFileSpec
|
||||
// one kind of concatenation of "paths".
|
||||
void SetLeafName(const nsString& inLeafName)
|
||||
{
|
||||
const nsAutoCString leafName(inLeafName);
|
||||
SetLeafName(leafName);
|
||||
SetLeafName(nsAutoCString(inLeafName));
|
||||
}
|
||||
void GetParent(nsFileSpec& outSpec) const;
|
||||
// Return the filespec of the parent directory. Used
|
||||
@@ -319,35 +294,12 @@ class NS_BASE nsFileSpec
|
||||
// but a spec. Volumes on Macintosh can have identical
|
||||
// names. Perhaps could be used for an operator --() ?
|
||||
|
||||
typedef PRUint32 TimeStamp; // ie nsFileSpec::TimeStamp. This is 32 bits now,
|
||||
// but might change, eg, to a 64-bit class. So use the
|
||||
// typedef, and use a streaming operator to convert
|
||||
// to a string, so that your code won't break. It's
|
||||
// none of your business what the number means. Don't
|
||||
// rely on the implementation.
|
||||
void GetModDate(TimeStamp& outStamp) const;
|
||||
// This will return different values on different
|
||||
// platforms, even for the same file (eg, on a server).
|
||||
// But if the platform is constant, it will increase after
|
||||
// every file modification.
|
||||
PRBool ModDateChanged(const TimeStamp& oldStamp) const
|
||||
{
|
||||
TimeStamp newStamp;
|
||||
GetModDate(newStamp);
|
||||
return newStamp != oldStamp;
|
||||
}
|
||||
|
||||
PRUint32 GetFileSize() const;
|
||||
PRUint32 GetDiskSpaceAvailable() const;
|
||||
|
||||
nsFileSpec operator + (const char* inRelativePath) const;
|
||||
nsFileSpec operator + (const nsString& inRelativePath) const
|
||||
{
|
||||
const nsAutoCString
|
||||
relativePath(inRelativePath);
|
||||
return *this + relativePath;
|
||||
return *this + nsAutoCString(inRelativePath);
|
||||
}
|
||||
void operator += (const char* inRelativePath);
|
||||
void operator += (const char* inRelativePath);
|
||||
// Concatenate the relative path to this directory.
|
||||
// Used for constructing the filespec of a descendant.
|
||||
// This must be a directory for this to work. This differs
|
||||
@@ -356,18 +308,16 @@ class NS_BASE nsFileSpec
|
||||
// away its leaf information, whereas this one assumes
|
||||
// this is a directory, and the relative path starts
|
||||
// "below" this.
|
||||
void operator += (const nsString& inRelativePath)
|
||||
void operator += (const nsString& inRelativePath)
|
||||
{
|
||||
const nsAutoCString relativePath(inRelativePath);
|
||||
*this += relativePath;
|
||||
*this += nsAutoCString(inRelativePath);
|
||||
}
|
||||
|
||||
void MakeUnique();
|
||||
void MakeUnique(const char* inSuggestedLeafName);
|
||||
void MakeUnique(const nsString& inSuggestedLeafName)
|
||||
{
|
||||
const nsAutoCString suggestedLeafName(inSuggestedLeafName);
|
||||
MakeUnique(suggestedLeafName);
|
||||
MakeUnique(nsAutoCString(inSuggestedLeafName));
|
||||
}
|
||||
|
||||
PRBool IsDirectory() const;
|
||||
@@ -386,34 +336,27 @@ class NS_BASE nsFileSpec
|
||||
nsresult Rename(const char* inNewName); // not const: gets updated
|
||||
nsresult Rename(const nsString& inNewName)
|
||||
{
|
||||
const nsAutoCString newName(inNewName);
|
||||
return Rename(newName);
|
||||
return Rename(nsAutoCString(inNewName));
|
||||
}
|
||||
nsresult Copy(const nsFileSpec& inNewParentDirectory) const;
|
||||
nsresult Move(const nsFileSpec& inNewParentDirectory) const;
|
||||
nsresult Execute(const char* args) const;
|
||||
nsresult Execute(const nsString& args) const
|
||||
{
|
||||
const nsAutoCString argsString(args);
|
||||
return Execute(argsString);
|
||||
return Execute(nsAutoCString(args));
|
||||
}
|
||||
|
||||
protected:
|
||||
#ifdef XP_MAC
|
||||
OSErr GetCatInfo(CInfoPBRec& outInfo) const;
|
||||
#endif
|
||||
//--------------------------------------------------
|
||||
// Data
|
||||
//--------------------------------------------------
|
||||
|
||||
protected:
|
||||
private:
|
||||
friend class nsFilePath;
|
||||
friend class nsFileURL;
|
||||
friend class nsDirectoryIterator;
|
||||
#ifdef XP_MAC
|
||||
FSSpec mSpec;
|
||||
#endif
|
||||
#else
|
||||
char* mPath;
|
||||
#endif
|
||||
nsresult mError;
|
||||
}; // class nsFileSpec
|
||||
|
||||
@@ -444,15 +387,11 @@ class NS_BASE nsFileURL
|
||||
void operator = (const char* inString);
|
||||
void operator = (const nsString& inString)
|
||||
{
|
||||
const nsAutoCString string(inString);
|
||||
*this = string;
|
||||
*this = nsAutoCString(inString);
|
||||
}
|
||||
void operator = (const nsFilePath& inOther);
|
||||
void operator = (const nsFileSpec& inOther);
|
||||
|
||||
operator const char* () const { return mURL; } // deprecated.
|
||||
const char* GetAsString() const { return mURL; }
|
||||
|
||||
friend NS_BASE nsOutputStream& operator << (
|
||||
nsOutputStream& s, const nsFileURL& spec);
|
||||
|
||||
@@ -463,7 +402,8 @@ class NS_BASE nsFileURL
|
||||
private:
|
||||
// Should not be defined (only nsFilePath is to be treated as strings.
|
||||
operator char* ();
|
||||
protected:
|
||||
operator const char* const ();
|
||||
private:
|
||||
friend class nsFilePath; // to allow construction of nsFilePath
|
||||
char* mURL;
|
||||
#ifdef XP_MAC
|
||||
@@ -475,9 +415,8 @@ class NS_BASE nsFileURL
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsFilePath
|
||||
// This is a string that looks like "/foo/bar/mumble fish". Same as nsFileURL, but
|
||||
// without the "file:// prefix", and NOT %20 ENCODED! Strings passed in must be
|
||||
// valid unix-style paths in this format.
|
||||
// This is a string that looks like "/foo/bar/mumble%20fish". Same as nsFileURL, but
|
||||
// without the "file:// prefix".
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
@@ -502,8 +441,7 @@ class NS_BASE nsFilePath
|
||||
void operator = (const char* inString);
|
||||
void operator = (const nsString& inString)
|
||||
{
|
||||
const nsAutoCString string(inString);
|
||||
*this = string;
|
||||
*this = nsAutoCString(inString);
|
||||
}
|
||||
void operator = (const nsFileURL& inURL);
|
||||
void operator = (const nsFileSpec& inOther);
|
||||
@@ -526,10 +464,6 @@ class NS_BASE nsFilePath
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsPersistentFileDescriptor
|
||||
// To save information about a file's location in another file, initialize
|
||||
// one of these from your nsFileSpec, and then write this out to your output stream.
|
||||
// To retrieve the info, create one of these, read its value from an input stream.
|
||||
// and then make an nsFileSpec from it.
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
@@ -540,7 +474,7 @@ class NS_BASE nsPersistentFileDescriptor
|
||||
void operator = (const nsPersistentFileDescriptor& inPath);
|
||||
|
||||
// Conversions
|
||||
NS_EXPLICIT nsPersistentFileDescriptor(const nsFileSpec& inPath);
|
||||
nsPersistentFileDescriptor(const nsFileSpec& inPath);
|
||||
void operator = (const nsFileSpec& inPath);
|
||||
|
||||
nsresult Read(nsIInputStream* aStream);
|
||||
@@ -558,7 +492,7 @@ class NS_BASE nsPersistentFileDescriptor
|
||||
// DON'T FREE the returned data!
|
||||
void SetData(const void* inData, PRInt32 inSize);
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
char* mDescriptorString;
|
||||
|
||||
|
||||
@@ -35,10 +35,15 @@
|
||||
// the handy << or >> notation can be yours.
|
||||
//
|
||||
// nsInputFileStream, nsOutputFileStream
|
||||
// These are the STATICALLY LINKED wrappers for the file-related
|
||||
// versions of the above.
|
||||
// nsIOFileStream
|
||||
// An input and output file stream attached to the same file.
|
||||
// These are the STATICALLY LINKED versions of the file i/o streams,
|
||||
// which wrap the NSPR file i/o plus console i/o.
|
||||
//
|
||||
// Related files:
|
||||
// prio.h the NSPR file i/o C API), which is wrapped by
|
||||
// THIS FILE statically linked C++ wrappers, which in turn are wrapped by
|
||||
// nsIFileStream.h COM wrappers for this file, which are wrapped by
|
||||
// nsAutoFileStream.h more easily used, nicer syntax wrappers for the
|
||||
// COMified ones. Wrapper of a wrapper of a wrapper.
|
||||
//
|
||||
// This suite provide the following services:
|
||||
//
|
||||
@@ -86,14 +91,12 @@
|
||||
#include "prio.h"
|
||||
#endif
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
// Defined elsewhere
|
||||
class nsFileSpec;
|
||||
class nsString;
|
||||
class nsIInputStream;
|
||||
class nsIOutputStream;
|
||||
class nsInputFileStream;
|
||||
class nsOutputFileStream;
|
||||
|
||||
//========================================================================================
|
||||
// Compiler-specific macros, as needed
|
||||
@@ -177,7 +180,16 @@ public:
|
||||
{
|
||||
mInputStream->Close();
|
||||
}
|
||||
PRInt32 read(void* s, PRInt32 n);
|
||||
PRInt32 read(void* s, PRInt32 n)
|
||||
{
|
||||
if (!mInputStream)
|
||||
return 0;
|
||||
PRInt32 result = 0;
|
||||
mInputStream->Read((char*)s, 0, n, (PRUint32*)&result);
|
||||
if (result < n)
|
||||
set_at_eof(PR_TRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Input streamers. Add more as needed (int&, unsigned int& etc). (but you have to
|
||||
// add delegators to the derived classes, too, because these operators don't inherit).
|
||||
@@ -238,7 +250,14 @@ public:
|
||||
mOutputStream->Close();
|
||||
}
|
||||
void put(char c);
|
||||
PRInt32 write(const void* s, PRInt32 n);
|
||||
PRInt32 write(const void* s, PRInt32 n)
|
||||
{
|
||||
if (!mOutputStream)
|
||||
return 0;
|
||||
PRInt32 result = 0;
|
||||
mOutputStream->Write((char*)s, 0, n, (PRUint32*)&result);
|
||||
return result;
|
||||
}
|
||||
virtual void flush();
|
||||
|
||||
// Output streamers. Add more as needed (but you have to add delegators to the derived
|
||||
@@ -249,8 +268,6 @@ public:
|
||||
nsOutputStream& operator << (unsigned short val);
|
||||
nsOutputStream& operator << (long val);
|
||||
nsOutputStream& operator << (unsigned long val);
|
||||
nsOutputStream& operator << (int val);
|
||||
nsOutputStream& operator << (unsigned int val);
|
||||
|
||||
// Support manipulators
|
||||
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
|
||||
@@ -265,41 +282,29 @@ protected:
|
||||
|
||||
typedef nsOutputStream nsBasicOutStream; // Historic support for this name
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsErrorProne
|
||||
// Common (virtual) base class for remembering errors on demand
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
nsErrorProne() // for delayed opening
|
||||
: mResult(NS_OK)
|
||||
{
|
||||
}
|
||||
PRBool failed() const
|
||||
{
|
||||
return NS_FAILED(mResult);
|
||||
}
|
||||
|
||||
// DATA
|
||||
protected:
|
||||
nsresult mResult;
|
||||
}; // class nsErrorProne
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsFileClient
|
||||
// Because COM does not allow us to write functions which return a boolean value etc,
|
||||
// this class is here to take care of the tedious "declare variable then call with
|
||||
// the address of the variable" chores.
|
||||
//========================================================================================
|
||||
: public virtual nsErrorProne
|
||||
{
|
||||
public:
|
||||
nsFileClient() // for delayed opening
|
||||
: mResult(NS_OK)
|
||||
{
|
||||
}
|
||||
nsFileClient(const nsCOMPtr<nsIFile>& inFile)
|
||||
: mFile(do_QueryInterface(inFile))
|
||||
, mResult(NS_OK)
|
||||
{
|
||||
}
|
||||
virtual ~nsFileClient() {}
|
||||
|
||||
|
||||
PRBool is_file() const
|
||||
{
|
||||
return mFile ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
void open(
|
||||
const nsFileSpec& inFile,
|
||||
int nsprMode,
|
||||
@@ -315,39 +320,10 @@ public:
|
||||
mFile->GetIsOpen(&result);
|
||||
return result;
|
||||
}
|
||||
PRBool is_file() const
|
||||
PRBool failed() const
|
||||
{
|
||||
return mFile ? PR_TRUE : PR_FALSE;
|
||||
return NS_FAILED(mResult);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
nsFileClient() // for delayed opening
|
||||
{
|
||||
}
|
||||
// DATA
|
||||
protected:
|
||||
nsCOMPtr<nsIFile> mFile;
|
||||
}; // class nsFileClient
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsRandomAccessStoreClient
|
||||
// Because COM does not allow us to write functions which return a boolean value etc,
|
||||
// this class is here to take care of the tedious "declare variable then call with
|
||||
// the address of the variable" chores.
|
||||
//========================================================================================
|
||||
: public virtual nsErrorProne
|
||||
{
|
||||
public:
|
||||
nsRandomAccessStoreClient() // for delayed opening
|
||||
{
|
||||
}
|
||||
nsRandomAccessStoreClient(const nsCOMPtr<nsIRandomAccessStore>& inStore)
|
||||
: mStore(do_QueryInterface(inStore))
|
||||
{
|
||||
}
|
||||
virtual ~nsRandomAccessStoreClient() {}
|
||||
|
||||
void seek(PRInt32 offset)
|
||||
{
|
||||
seek(PR_SEEK_SET, offset);
|
||||
@@ -356,109 +332,49 @@ public:
|
||||
void seek(PRSeekWhence whence, PRInt32 offset)
|
||||
{
|
||||
set_at_eof(PR_FALSE);
|
||||
if (mStore)
|
||||
mResult = mStore->Seek(whence, offset);
|
||||
if (mFile)
|
||||
mResult = mFile->Seek(whence, offset);
|
||||
}
|
||||
PRIntn tell()
|
||||
{
|
||||
PRIntn result = -1;
|
||||
if (mStore)
|
||||
mResult = mStore->Tell(&result);
|
||||
if (mFile)
|
||||
mResult = mFile->Tell(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRBool get_at_eof() const
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
if (mStore)
|
||||
mStore->GetAtEOF(&result);
|
||||
PRBool result;
|
||||
if (mFile)
|
||||
mFile->GetAtEOF(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual void set_at_eof(PRBool atEnd)
|
||||
{
|
||||
if (mStore)
|
||||
mStore->SetAtEOF(atEnd);
|
||||
if (mFile)
|
||||
mFile->SetAtEOF(atEnd);
|
||||
}
|
||||
|
||||
// DATA
|
||||
protected:
|
||||
nsCOMPtr<nsIRandomAccessStore> mStore;
|
||||
}; // class nsRandomAccessStoreClient
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsRandomAccessInputStream
|
||||
// Please read the comments at the top of this file
|
||||
//========================================================================================
|
||||
: public nsRandomAccessStoreClient
|
||||
, public nsInputStream
|
||||
{
|
||||
public:
|
||||
nsRandomAccessInputStream(nsIInputStream* inStream)
|
||||
: nsRandomAccessStoreClient(do_QueryInterface(inStream))
|
||||
, nsInputStream(inStream)
|
||||
{
|
||||
}
|
||||
PRBool readline(char* s, PRInt32 n);
|
||||
// Result always null-terminated.
|
||||
// Check eof() before each call.
|
||||
// CAUTION: false result only indicates line was truncated
|
||||
// to fit buffer, or an error occurred (OTHER THAN eof).
|
||||
|
||||
// Input streamers. Unfortunately, they don't inherit!
|
||||
nsInputStream& operator >> (char& ch)
|
||||
{ return nsInputStream::operator >>(ch); }
|
||||
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
|
||||
{ return nsInputStream::operator >>(pf); }
|
||||
|
||||
protected:
|
||||
nsRandomAccessInputStream()
|
||||
: nsInputStream(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
virtual PRBool get_at_eof() const
|
||||
{
|
||||
return nsRandomAccessStoreClient::get_at_eof();
|
||||
}
|
||||
|
||||
virtual void set_at_eof(PRBool atEnd)
|
||||
{
|
||||
nsRandomAccessStoreClient::set_at_eof(atEnd);
|
||||
}
|
||||
|
||||
}; // class nsRandomAccessInputStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsInputStringStream
|
||||
//========================================================================================
|
||||
: public nsRandomAccessInputStream
|
||||
{
|
||||
public:
|
||||
nsInputStringStream(const char* stringToRead);
|
||||
nsInputStringStream(const nsString& stringToRead);
|
||||
|
||||
// Input streamers. Unfortunately, they don't inherit!
|
||||
nsInputStream& operator >> (char& ch)
|
||||
{ return nsInputStream::operator >>(ch); }
|
||||
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
|
||||
{ return nsInputStream::operator >>(pf); }
|
||||
|
||||
}; // class nsInputStringStream
|
||||
nsCOMPtr<nsIFile> mFile;
|
||||
PRBool mResult;
|
||||
}; // class nsFileClient
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsInputFileStream
|
||||
// Please read the comments at the top of this file
|
||||
//========================================================================================
|
||||
: public nsRandomAccessInputStream
|
||||
, public nsFileClient
|
||||
: public nsInputStream
|
||||
, public nsFileClient
|
||||
{
|
||||
public:
|
||||
enum { kDefaultMode = PR_RDONLY };
|
||||
nsInputFileStream(nsIInputStream* inStream)
|
||||
: nsRandomAccessInputStream(inStream)
|
||||
: nsInputStream(inStream)
|
||||
, nsFileClient(do_QueryInterface(inStream))
|
||||
, mFileInputStream(do_QueryInterface(inStream))
|
||||
{
|
||||
@@ -466,12 +382,29 @@ public:
|
||||
nsInputFileStream(
|
||||
const nsFileSpec& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700); // <- OCTAL
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
: nsInputStream(nsnull)
|
||||
{
|
||||
nsISupports* stream;
|
||||
NS_NewIOFileStream(
|
||||
&stream,
|
||||
inFile, nsprMode, accessMode);
|
||||
mFile = nsQueryInterface(stream);
|
||||
mInputStream = nsQueryInterface(stream);
|
||||
mFileInputStream = nsQueryInterface(stream);
|
||||
NS_RELEASE(stream);
|
||||
}
|
||||
|
||||
PRBool readline(char* s, PRInt32 n);
|
||||
// Result always null-terminated.
|
||||
// Check eof() before each call.
|
||||
// CAUTION: false result only indicates line was truncated
|
||||
// to fit buffer, or an error occurred (OTHER THAN eof).
|
||||
|
||||
void Open(
|
||||
const nsFileSpec& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
const nsFileSpec& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
{
|
||||
if (mFile)
|
||||
mFile->Open(inFile, nsprMode, accessMode);
|
||||
@@ -483,99 +416,47 @@ public:
|
||||
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
|
||||
{ return nsInputStream::operator >>(pf); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRBool get_at_eof() const
|
||||
{
|
||||
return nsFileClient::get_at_eof();
|
||||
}
|
||||
|
||||
virtual void set_at_eof(PRBool atEnd)
|
||||
{
|
||||
nsFileClient::set_at_eof(atEnd);
|
||||
}
|
||||
|
||||
|
||||
// DATA
|
||||
protected:
|
||||
nsCOMPtr<nsIFileInputStream> mFileInputStream;
|
||||
}; // class nsInputFileStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsRandomAccessOutputStream
|
||||
// Please read the comments at the top of this file
|
||||
//========================================================================================
|
||||
: public nsRandomAccessStoreClient
|
||||
, public nsOutputStream
|
||||
{
|
||||
public:
|
||||
nsRandomAccessOutputStream(nsIOutputStream* inStream)
|
||||
: nsRandomAccessStoreClient(do_QueryInterface(inStream))
|
||||
, nsOutputStream(inStream)
|
||||
{
|
||||
}
|
||||
|
||||
// Output streamers. Unfortunately, they don't inherit!
|
||||
nsOutputStream& operator << (const char* buf)
|
||||
{ return nsOutputStream::operator << (buf); }
|
||||
nsOutputStream& operator << (char ch)
|
||||
{ return nsOutputStream::operator << (ch); }
|
||||
nsOutputStream& operator << (short val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned short val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (long val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned long val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
|
||||
{ return nsOutputStream::operator << (pf); }
|
||||
|
||||
protected:
|
||||
nsRandomAccessOutputStream()
|
||||
: nsOutputStream(nsnull)
|
||||
{
|
||||
}
|
||||
}; // class nsRandomAccessOutputStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsOutputStringStream
|
||||
//========================================================================================
|
||||
: public nsRandomAccessOutputStream
|
||||
{
|
||||
public:
|
||||
nsOutputStringStream(char*& stringToChange);
|
||||
nsOutputStringStream(nsString& stringToChange);
|
||||
|
||||
// Output streamers. Unfortunately, they don't inherit!
|
||||
nsOutputStream& operator << (const char* buf)
|
||||
{ return nsOutputStream::operator << (buf); }
|
||||
nsOutputStream& operator << (char ch)
|
||||
{ return nsOutputStream::operator << (ch); }
|
||||
nsOutputStream& operator << (short val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned short val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (long val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned long val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
|
||||
{ return nsOutputStream::operator << (pf); }
|
||||
|
||||
}; // class nsOutputStringStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsOutputFileStream
|
||||
// Please read the comments at the top of this file
|
||||
//========================================================================================
|
||||
: public nsRandomAccessOutputStream
|
||||
: public nsOutputStream
|
||||
, public nsFileClient
|
||||
{
|
||||
public:
|
||||
enum { kDefaultMode = (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE) };
|
||||
|
||||
nsOutputFileStream() {}
|
||||
nsOutputFileStream(nsIOutputStream* inStream)
|
||||
: nsOutputStream(inStream)
|
||||
, nsFileClient(do_QueryInterface(inStream))
|
||||
, mFileOutputStream(do_QueryInterface(inStream))
|
||||
{
|
||||
}
|
||||
nsOutputFileStream(
|
||||
const nsFileSpec& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
{
|
||||
: nsOutputStream(nsnull)
|
||||
{
|
||||
nsISupports* stream;
|
||||
if (NS_FAILED(NS_NewIOFileStream(
|
||||
&stream,
|
||||
@@ -583,7 +464,6 @@ public:
|
||||
return;
|
||||
mFile = nsQueryInterface(stream);
|
||||
mOutputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
mFileOutputStream = nsQueryInterface(stream);
|
||||
NS_RELEASE(stream);
|
||||
}
|
||||
@@ -603,13 +483,21 @@ public:
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned long val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
|
||||
{ return nsOutputStream::operator << (pf); }
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRBool get_at_eof() const
|
||||
{
|
||||
return nsFileClient::get_at_eof();
|
||||
}
|
||||
|
||||
virtual void set_at_eof(PRBool atEnd)
|
||||
{
|
||||
nsFileClient::set_at_eof(atEnd);
|
||||
}
|
||||
|
||||
// DATA
|
||||
protected:
|
||||
nsCOMPtr<nsIFileOutputStream> mFileOutputStream;
|
||||
@@ -647,10 +535,6 @@ public:
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned long val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
|
||||
{ return nsOutputStream::operator << (pf); }
|
||||
|
||||
@@ -687,7 +571,6 @@ public:
|
||||
inFile, nsprMode, accessMode)))
|
||||
return;
|
||||
mFile = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
mInputStream = nsQueryInterface(stream);
|
||||
mOutputStream = nsQueryInterface(stream);
|
||||
mFileInputStream = nsQueryInterface(stream);
|
||||
@@ -715,10 +598,6 @@ public:
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned long val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (unsigned int val)
|
||||
{ return nsOutputStream::operator << (val); }
|
||||
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
|
||||
{ return nsOutputStream::operator << (pf); }
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ class nsFileSpec;
|
||||
|
||||
//========================================================================================
|
||||
class nsIFile
|
||||
// Represents a file, and supports Open.
|
||||
// Represents a file, and supports Open, Tell etc.
|
||||
//========================================================================================
|
||||
: public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IFILE_IID; return iid; }
|
||||
static const nsIID& IID() { static nsIID iid = NS_IFILE_IID; return iid; }
|
||||
NS_IMETHOD Open(
|
||||
const nsFileSpec& inFile,
|
||||
int nsprMode,
|
||||
@@ -44,30 +44,14 @@ public:
|
||||
// Note: Open() is only needed after
|
||||
// an explicit Close(). All file streams
|
||||
// are automatically opened on construction.
|
||||
NS_IMETHOD GetIsOpen(PRBool* outOpen) = 0;
|
||||
|
||||
}; // class nsIFile
|
||||
|
||||
/* a6cf90e8-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_IRANDOMACCESS_IID \
|
||||
{ 0xa6cf90eb, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
//========================================================================================
|
||||
class nsIRandomAccessStore
|
||||
// Supports Seek, Tell etc.
|
||||
//========================================================================================
|
||||
: public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRANDOMACCESS_IID; return iid; }
|
||||
NS_IMETHOD Seek(PRSeekWhence whence, PRInt32 offset) = 0;
|
||||
NS_IMETHOD GetIsOpen(PRBool* outOpen) = 0;
|
||||
NS_IMETHOD Tell(PRIntn* outWhere) = 0;
|
||||
|
||||
/* "PROTECTED" */
|
||||
NS_IMETHOD GetAtEOF(PRBool* outAtEOF) = 0;
|
||||
NS_IMETHOD SetAtEOF(PRBool inAtEOF) = 0;
|
||||
}; // class nsIRandomAccessStore
|
||||
}; // class nsIFile
|
||||
|
||||
/* a6cf90e6-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_IFILEINPUTSTREAM_IID \
|
||||
@@ -80,10 +64,10 @@ class nsIFileInputStream
|
||||
// nsIInputStream supports. The current implementation supports both
|
||||
// interfaces.
|
||||
//========================================================================================
|
||||
: public nsIInputStream
|
||||
: public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IFILEINPUTSTREAM_IID; return iid; }
|
||||
static const nsIID& IID() { static nsIID iid = NS_IFILEINPUTSTREAM_IID; return iid; }
|
||||
}; // class nsIFileInputStream
|
||||
|
||||
/* a6cf90e7-15b3-11d2-932e-00805f8add32 */
|
||||
@@ -97,10 +81,10 @@ class nsIFileOutputStream
|
||||
// nsIOutputStream supports. The current implementation supports both
|
||||
// interfaces.
|
||||
//========================================================================================
|
||||
: public nsIOutputStream
|
||||
: public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IFILEOUTPUTSTREAM_IID; return iid; }
|
||||
static const nsIID& IID() { static nsIID iid = NS_IFILEOUTPUTSTREAM_IID; return iid; }
|
||||
NS_IMETHOD Flush() = 0;
|
||||
// Forces a write to disk.
|
||||
}; // class nsIFileOutputStream
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsIStringStream_h___
|
||||
#define nsIStringStream_h___
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsString.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewStringInputStream(
|
||||
nsISupports** aStreamResult,
|
||||
const nsString& aStringToRead);
|
||||
// Factory method to get an nsInputStream from a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewStringOutputStream(
|
||||
nsISupports** aStreamResult,
|
||||
nsString& aStringToChange);
|
||||
// Factory method to get an nsOutputStream from a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewCharInputStream(
|
||||
nsISupports** aStreamResult,
|
||||
const char* aStringToRead);
|
||||
// Factory method to get an nsInputStream from a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewCharOutputStream(
|
||||
nsISupports** aStreamResult,
|
||||
char** aStringToChange);
|
||||
// Factory method to get an nsOutputStream to a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewStringIOStream(
|
||||
nsISupports** aStreamResult,
|
||||
nsString& aStringToChange);
|
||||
// Factory method to get an nsOutputStream to a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewCharIOStream(
|
||||
nsISupports** aStreamResult,
|
||||
char** aStringToChange);
|
||||
// Factory method to get an nsOutputStream to a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
|
||||
#endif /* nsIStringStream_h___ */
|
||||
@@ -1,84 +0,0 @@
|
||||
/* -*- 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.0 (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.
|
||||
*
|
||||
* Contributors:
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef _NSSPECIALSYSTEMDIRECTORY_H_
|
||||
#define _NSSPECIALSYSTEMDIRECTORY_H_
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "Types.h"
|
||||
#endif
|
||||
|
||||
// SEE ALSO:
|
||||
// mozilla/xpfe/appshell/public/nsFileLocations.h
|
||||
|
||||
class NS_BASE nsSpecialSystemDirectory : public nsFileSpec
|
||||
{
|
||||
|
||||
public:
|
||||
enum SystemDirectories
|
||||
{
|
||||
OS_DriveDirectory = 1
|
||||
, OS_TemporaryDirectory = 2
|
||||
, OS_CurrentProcessDirectory= 3
|
||||
|
||||
, Mac_SystemDirectory = 101
|
||||
, Mac_DesktopDirectory = 102
|
||||
, Mac_TrashDirectory = 103
|
||||
, Mac_StartupDirectory = 104
|
||||
, Mac_ShutdownDirectory = 105
|
||||
, Mac_AppleMenuDirectory = 106
|
||||
, Mac_ControlPanelDirectory = 107
|
||||
, Mac_ExtensionDirectory = 108
|
||||
, Mac_FontsDirectory = 109
|
||||
, Mac_PreferencesDirectory = 110
|
||||
, Mac_DocumentsDirectory = 111
|
||||
|
||||
, Win_SystemDirectory = 201
|
||||
, Win_WindowsDirectory = 202
|
||||
|
||||
, Unix_LocalDirectory = 301
|
||||
, Unix_LibDirectory = 302
|
||||
};
|
||||
|
||||
//nsSpecialSystemDirectory();
|
||||
nsSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory);
|
||||
|
||||
virtual ~nsSpecialSystemDirectory();
|
||||
|
||||
void operator = (SystemDirectories aSystemSystemDirectory);
|
||||
|
||||
#ifdef XP_MAC
|
||||
void operator = (OSType folderType);
|
||||
nsSpecialSystemDirectory(OSType folderType);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void operator = (const char* inPath) { *(nsFileSpec*)this = inPath; }
|
||||
|
||||
}; // class NS_BASE nsSpecialSystemDirectory
|
||||
|
||||
#endif
|
||||
@@ -24,8 +24,6 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DEFINES +=-D_IMPL_NS_BASE
|
||||
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/base/public
|
||||
|
||||
DIRS = $(MOZ_TOOLKIT)
|
||||
|
||||
LIBRARY_NAME = raptorbase
|
||||
@@ -41,16 +39,14 @@ CPPSRCS = \
|
||||
nsEscape.cpp \
|
||||
nsFileSpec.cpp \
|
||||
nsFileStream.cpp \
|
||||
nsIFileStream.cpp \
|
||||
nsIStringStream.cpp \
|
||||
nsIFileStream.cpp \
|
||||
nsProperties.cpp \
|
||||
nsRBTree.cpp \
|
||||
nsSizeOfHandler.cpp \
|
||||
nsSizeOfHandler.cpp \
|
||||
nsString.cpp \
|
||||
nsUnicharBuffer.cpp \
|
||||
nsUnicharInputStream.cpp \
|
||||
nsVoidArray.cpp \
|
||||
nsSpecialSystemDirectory.cpp\
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
||||
@@ -37,6 +37,6 @@ CPPSRCS = \
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -29,7 +29,7 @@ nsCaretProperties::nsCaretProperties()
|
||||
{
|
||||
// in your platform-specific class, get data from the OS in your constructor
|
||||
|
||||
//mBlinkRate = 0; // don't blink the caret
|
||||
mBlinkRate = 0; // don't blink the caret
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -131,7 +131,6 @@ TimerImpl::Init(nsITimerCallback *aCallback,
|
||||
{
|
||||
//printf("TimerImpl::Init called with callback only for %p\n", this);
|
||||
mCallback = aCallback;
|
||||
NS_ADDREF(mCallback);
|
||||
// mRepeat = aRepeat;
|
||||
if ((aDelay > 10000) || (aDelay < 0)) {
|
||||
printf("Timer::Init() called with bogus value \"%d\"! Not enabling timer.\n",
|
||||
@@ -150,7 +149,7 @@ TimerImpl::Init(PRUint32 aDelay)
|
||||
//printf("TimerImpl::Init called with delay %d only for %p\n", aDelay, this);
|
||||
|
||||
mDelay = aDelay;
|
||||
// NS_ADDREF(this);
|
||||
NS_ADDREF(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "FullPath.h"
|
||||
#include "FileCopy.h"
|
||||
#include "MoreFilesExtras.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
#include <Aliases.h>
|
||||
#include <Folders.h>
|
||||
@@ -44,23 +45,20 @@ namespace MacFileHelpers
|
||||
void PLstrncpy(Str255 dst, const char* src, int inMaxLen);
|
||||
|
||||
void SwapSlashColon(char * s);
|
||||
OSErr FSSpecFromUnixPath(
|
||||
OSErr FSSpecFromFullUnixPath(
|
||||
const char * unixPath,
|
||||
FSSpec& ioSpec,
|
||||
Boolean hexDecode,
|
||||
FSSpec& outSpec,
|
||||
Boolean resolveAlias,
|
||||
Boolean allowPartial = false,
|
||||
Boolean createDirs = false);
|
||||
char* MacPathFromUnixPath(
|
||||
const char* unixPath,
|
||||
Boolean hexDecode);
|
||||
char* MacPathFromUnixPath(const char* unixPath);
|
||||
char* EncodeMacPath(
|
||||
char* inPath, // NOT const - gets clobbered
|
||||
Boolean prependSlash,
|
||||
Boolean doEscape );
|
||||
OSErr FSSpecFromPathname(
|
||||
const char* inPathNamePtr,
|
||||
FSSpec& ioSpec,
|
||||
FSSpec& outSpec,
|
||||
Boolean inCreateDirs);
|
||||
char* PathNameFromFSSpec(
|
||||
const FSSpec& inSpec,
|
||||
@@ -214,7 +212,7 @@ OSErr MacFileHelpers::MakeAliasSafe(FSSpec& inOutSpec)
|
||||
} // MacFileHelpers::MakeAliasSafe
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath, Boolean hexDecode)
|
||||
char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Relying on the fact that the unix path is always longer than the mac path:
|
||||
@@ -229,8 +227,7 @@ char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath, Boolean hexDecod
|
||||
else if (strchr(src, '/')) // * partial path, and not just a leaf name
|
||||
*dst++ = ':';
|
||||
strcpy(dst, src);
|
||||
if (hexDecode)
|
||||
nsUnescape(dst); // Hex Decode
|
||||
nsUnescape(dst); // Hex Decode
|
||||
MacFileHelpers::SwapSlashColon(dst);
|
||||
}
|
||||
return result;
|
||||
@@ -239,7 +236,7 @@ char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath, Boolean hexDecod
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr MacFileHelpers::FSSpecFromPathname(
|
||||
const char* inPathNamePtr,
|
||||
FSSpec& ioSpec, // used as in-parameter for a relative path.
|
||||
FSSpec& outSpec,
|
||||
Boolean inCreateDirs)
|
||||
// FSSpecFromPathname reverses PathNameFromFSSpec.
|
||||
// It returns a FSSpec given a c string which is a mac pathname.
|
||||
@@ -250,26 +247,20 @@ OSErr MacFileHelpers::FSSpecFromPathname(
|
||||
// routine FSpLocationFromFullPath, which allocates memory, to handle longer pathnames.
|
||||
|
||||
size_t inLength = strlen(inPathNamePtr);
|
||||
bool isRelative = (strchr(inPathNamePtr, ':') == 0 || *inPathNamePtr == ':');
|
||||
if (inLength < 255)
|
||||
{
|
||||
Str255 ppath;
|
||||
MacFileHelpers::PLstrcpy(ppath, inPathNamePtr);
|
||||
if (isRelative)
|
||||
err = ::FSMakeFSSpec(ioSpec.vRefNum, ioSpec.parID, ppath, &ioSpec);
|
||||
else
|
||||
err = ::FSMakeFSSpec(0, 0, ppath, &ioSpec);
|
||||
err = ::FSMakeFSSpec(0, 0, ppath, &outSpec);
|
||||
}
|
||||
else if (!isRelative)
|
||||
err = FSpLocationFromFullPath(inLength, inPathNamePtr, &ioSpec);
|
||||
else
|
||||
err = bdNamErr;
|
||||
else
|
||||
err = FSpLocationFromFullPath(inLength, inPathNamePtr, &outSpec);
|
||||
|
||||
if ((err == dirNFErr || err == bdNamErr) && inCreateDirs)
|
||||
if (err == dirNFErr && inCreateDirs)
|
||||
{
|
||||
const char* path = inPathNamePtr;
|
||||
ioSpec.vRefNum = 0;
|
||||
ioSpec.parID = 0;
|
||||
outSpec.vRefNum = 0;
|
||||
outSpec.parID = 0;
|
||||
do {
|
||||
// Locate the colon that terminates the node.
|
||||
// But if we've a partial path (starting with a colon), find the second one.
|
||||
@@ -285,7 +276,7 @@ OSErr MacFileHelpers::FSSpecFromPathname(
|
||||
|
||||
// Use this string as a relative path using the directory created
|
||||
// on the previous round (or directory 0,0 on the first round).
|
||||
err = ::FSMakeFSSpec(ioSpec.vRefNum, ioSpec.parID, ppath, &ioSpec);
|
||||
err = ::FSMakeFSSpec(outSpec.vRefNum, outSpec.parID, ppath, &outSpec);
|
||||
|
||||
// If this was the leaf node, then we are done.
|
||||
if (!*nextColon)
|
||||
@@ -294,7 +285,7 @@ OSErr MacFileHelpers::FSSpecFromPathname(
|
||||
// If we got "file not found", then
|
||||
// we need to create a directory.
|
||||
if (err == fnfErr && *nextColon)
|
||||
err = FSpDirCreate(&ioSpec, smCurrentScript, &ioSpec.parID);
|
||||
err = FSpDirCreate(&outSpec, smCurrentScript, &outSpec.parID);
|
||||
// For some reason, this usually returns fnfErr, even though it works.
|
||||
if (err != noErr && err != fnfErr)
|
||||
return err;
|
||||
@@ -377,10 +368,9 @@ OSErr MacFileHelpers::ResolveAliasFile(FSSpec& inOutSpec, Boolean& wasAliased)
|
||||
} // MacFileHelpers::ResolveAliasFile
|
||||
|
||||
//-----------------------------------
|
||||
OSErr MacFileHelpers::FSSpecFromUnixPath(
|
||||
OSErr MacFileHelpers::FSSpecFromFullUnixPath(
|
||||
const char * unixPath,
|
||||
FSSpec& ioSpec,
|
||||
Boolean hexDecode,
|
||||
FSSpec& outSpec,
|
||||
Boolean resolveAlias,
|
||||
Boolean allowPartial,
|
||||
Boolean createDirs)
|
||||
@@ -392,7 +382,7 @@ OSErr MacFileHelpers::FSSpecFromUnixPath(
|
||||
{
|
||||
if (unixPath == nsnull)
|
||||
return badFidErr;
|
||||
char* macPath = MacPathFromUnixPath(unixPath, hexDecode);
|
||||
char* macPath = MacPathFromUnixPath(unixPath);
|
||||
if (!macPath)
|
||||
return memFullErr;
|
||||
|
||||
@@ -401,12 +391,12 @@ OSErr MacFileHelpers::FSSpecFromUnixPath(
|
||||
{
|
||||
NS_ASSERTION(*unixPath == '/' /*full path*/, "Not a full Unix path!");
|
||||
}
|
||||
err = FSSpecFromPathname(macPath, ioSpec, createDirs);
|
||||
err = FSSpecFromPathname(macPath, outSpec, createDirs);
|
||||
if (err == fnfErr)
|
||||
err = noErr;
|
||||
Boolean dummy;
|
||||
if (err == noErr && resolveAlias) // Added
|
||||
err = MacFileHelpers::ResolveAliasFile(ioSpec, dummy);
|
||||
err = MacFileHelpers::ResolveAliasFile(outSpec, dummy);
|
||||
delete [] macPath;
|
||||
NS_ASSERTION(err==noErr||err==fnfErr||err==dirNFErr||err==nsvErr, "Not a path!");
|
||||
return err;
|
||||
@@ -518,7 +508,6 @@ Clean:
|
||||
nsFileSpec::nsFileSpec()
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mError(NS_OK)
|
||||
, mPath(nsnull)
|
||||
{
|
||||
mSpec.name[0] = '\0';
|
||||
}
|
||||
@@ -527,7 +516,6 @@ nsFileSpec::nsFileSpec()
|
||||
nsFileSpec::nsFileSpec(const nsFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mSpec(inSpec.mSpec)
|
||||
, mPath(nsnull)
|
||||
, mError(inSpec.Error())
|
||||
{
|
||||
}
|
||||
@@ -535,15 +523,10 @@ nsFileSpec::nsFileSpec(const nsFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsnull)
|
||||
{
|
||||
mSpec.vRefNum = 0;
|
||||
mSpec.parID = 0;
|
||||
// Convert unix (non-encoded) path to a spec.
|
||||
mError = NS_FILE_RESULT(
|
||||
MacFileHelpers::FSSpecFromUnixPath(
|
||||
inString,
|
||||
mSpec, false, false, true, inCreateDirs));
|
||||
mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromFullUnixPath(
|
||||
inString, mSpec, false, true, inCreateDirs));
|
||||
// allow a partial path, create as necessary
|
||||
if (mError == NS_FILE_RESULT(fnfErr))
|
||||
mError = NS_OK;
|
||||
} // nsFileSpec::nsFileSpec
|
||||
@@ -551,57 +534,55 @@ nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsnull)
|
||||
{
|
||||
mSpec.vRefNum = 0;
|
||||
mSpec.parID = 0;
|
||||
// Convert unix (non-encoded) path to a spec.
|
||||
mError = NS_FILE_RESULT(
|
||||
MacFileHelpers::FSSpecFromUnixPath(
|
||||
nsAutoCString(inString),
|
||||
mSpec, false, false, true, inCreateDirs));
|
||||
mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromFullUnixPath(
|
||||
nsAutoCString(inString), mSpec, false, true, inCreateDirs));
|
||||
// allow a partial path, create as necessary
|
||||
if (mError == NS_FILE_RESULT(fnfErr))
|
||||
mError = NS_OK;
|
||||
} // nsFileSpec::nsFileSpec
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec::nsFileSpec(short vRefNum, long parID, ConstStr255Param name)
|
||||
nsFileSpec::nsFileSpec(
|
||||
short vRefNum,
|
||||
long parID,
|
||||
ConstStr255Param name)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsnull)
|
||||
{
|
||||
mError = NS_FILE_RESULT(::FSMakeFSSpec(vRefNum, parID, name, &mSpec));
|
||||
if (mError == NS_FILE_RESULT(fnfErr))
|
||||
mError = NS_OK;
|
||||
mError = noErr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec::nsFileSpec(const nsFilePath& inPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsnull)
|
||||
{
|
||||
*this = inPath.GetFileSpec();
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputStream& operator << (nsOutputStream& s, const nsFileSpec& spec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
s << spec.mSpec.vRefNum << ", " << spec.mSpec.parID << ", \"";
|
||||
s.write((const char*)&spec.mSpec.name[1], spec.mSpec.name[0]);
|
||||
return s << "\"";
|
||||
} // nsOutputStream& operator << (nsOutputStream&, const nsFileSpec&)
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpec::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, nsnull);
|
||||
|
||||
mSpec.vRefNum = 0;
|
||||
mSpec.parID = 0;
|
||||
// Convert unix (non-encoded) path to a spec.
|
||||
mError = NS_FILE_RESULT(
|
||||
MacFileHelpers::FSSpecFromUnixPath(inString, mSpec, false, false, true));
|
||||
if (mError == NS_FILE_RESULT(fnfErr))
|
||||
mError = NS_OK;
|
||||
mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromFullUnixPath(inString, mSpec, false));
|
||||
} // nsFileSpec::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpec::operator = (const nsFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, nsnull);
|
||||
mSpec = inSpec.mSpec;
|
||||
mError = inSpec.Error();
|
||||
} // nsFileSpec::operator =
|
||||
@@ -613,64 +594,24 @@ void nsFileSpec::operator = (const nsFilePath& inPath)
|
||||
*this = inPath.GetFileSpec();
|
||||
} // nsFileSpec::operator =
|
||||
|
||||
#if DEBUG
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputStream& operator << (nsOutputStream& s, const nsFileSpec& spec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#if 0
|
||||
s << spec.mSpec.vRefNum << ", " << spec.mSpec.parID << ", \"";
|
||||
s.write((const char*)&spec.mSpec.name[1], spec.mSpec.name[0]);
|
||||
return s << "\"";
|
||||
#else
|
||||
return s << "\"" << spec.GetCString() << "\"";
|
||||
#endif
|
||||
} // nsOutputStream& operator << (nsOutputStream&, const nsFileSpec&)
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRBool nsFileSpec::Exists() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
FSSpec temp;
|
||||
return ::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, mSpec.name, &temp) == noErr;
|
||||
} // nsFileSpec::Exists()
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpec::GetModDate(TimeStamp& outStamp) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CInfoPBRec pb;
|
||||
if (GetCatInfo(pb) == noErr)
|
||||
outStamp = ((DirInfo*)&pb)->ioDrMdDat; // The mod date is in the same spot for files and dirs.
|
||||
else
|
||||
outStamp = 0;
|
||||
} // nsFileSpec::GetModDate
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint32 nsFileSpec::GetFileSize() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CInfoPBRec pb;
|
||||
if (noErr == GetCatInfo(pb))
|
||||
return (PRUint32)((HFileInfo*)&pb)->ioFlLgLen;
|
||||
return 0;
|
||||
} // nsFileSpec::GetFileSize
|
||||
} // nsFileSpec::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpec::SetLeafName(const char* inLeafName)
|
||||
// In leaf name can actually be a partial path...
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, nsnull);
|
||||
|
||||
// what about long relative paths? Hmm? We don't have a routine for this anywhere.
|
||||
// what about long relative paths? Hmm?
|
||||
Str255 partialPath;
|
||||
MacFileHelpers::PLstrcpy(partialPath, inLeafName);
|
||||
mError = NS_FILE_RESULT(
|
||||
::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, partialPath, &mSpec));
|
||||
if (mError == NS_FILE_RESULT(fnfErr))
|
||||
mError = NS_OK;
|
||||
} // nsFileSpec::SetLeafName
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -688,7 +629,6 @@ char* nsFileSpec::GetLeafName() const
|
||||
void nsFileSpec::MakeAliasSafe()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, nsnull);
|
||||
mError = NS_FILE_RESULT(MacFileHelpers::MakeAliasSafe(mSpec));
|
||||
} // nsFileSpec::MakeAliasSafe
|
||||
|
||||
@@ -696,7 +636,6 @@ void nsFileSpec::MakeAliasSafe()
|
||||
void nsFileSpec::MakeUnique(ConstStr255Param inSuggestedLeafName)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, nsnull);
|
||||
if (inSuggestedLeafName[0] > 0)
|
||||
MacFileHelpers::PLstrcpy(mSpec.name, inSuggestedLeafName);
|
||||
|
||||
@@ -748,14 +687,11 @@ void nsFileSpec::operator += (const char* inRelativePath)
|
||||
mError = NS_FILE_RESULT(::FSpGetDirectoryID(&mSpec, &dirID, &isDirectory));
|
||||
if (NS_SUCCEEDED(mError) && isDirectory)
|
||||
{
|
||||
mSpec.parID = dirID;
|
||||
// mSpec.vRefNum is already correct.
|
||||
// Convert unix path (which is unencoded) to a spec
|
||||
mError = NS_FILE_RESULT(
|
||||
MacFileHelpers::FSSpecFromUnixPath(
|
||||
inRelativePath, mSpec, false, false, true, true));
|
||||
if (mError == NS_FILE_RESULT(fnfErr))
|
||||
mError = NS_OK;
|
||||
Str255 partialPath;
|
||||
MacFileHelpers::PLstrcpy(partialPath, inRelativePath);
|
||||
mError = NS_FILE_RESULT(::FSMakeFSSpec(mSpec.vRefNum, dirID, partialPath, *this));
|
||||
//if (NS_SUCCEEDED(mError))
|
||||
// SetLeafName(inRelativePath);
|
||||
}
|
||||
} // nsFileSpec::operator +=
|
||||
|
||||
@@ -764,7 +700,7 @@ void nsFileSpec::CreateDirectory(int /* unix mode */)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
long ignoredDirID;
|
||||
mError = NS_FILE_RESULT(FSpDirCreate(&mSpec, smCurrentScript, &ignoredDirID));
|
||||
FSpDirCreate(&mSpec, smCurrentScript, &ignoredDirID);
|
||||
} // nsFileSpec::CreateDirectory
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -857,54 +793,6 @@ nsresult nsFileSpec::Execute(const char* /*args - how can this be cross-platform
|
||||
|
||||
} // nsFileSpec::Execute
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsFileSpec::GetCatInfo(CInfoPBRec& outInfo) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
DirInfo *dipb=(DirInfo *)&outInfo;
|
||||
dipb->ioCompletion = nsnull;
|
||||
dipb->ioFDirIndex = 0; // use dirID and name
|
||||
dipb->ioVRefNum = mSpec.vRefNum;
|
||||
dipb->ioDrDirID = mSpec.parID;
|
||||
dipb->ioNamePtr = const_cast<nsFileSpec*>(this)->mSpec.name;
|
||||
return PBGetCatInfoSync(&outInfo);
|
||||
} // nsFileSpec::GetCatInfo()
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
HVolumeParam pb;
|
||||
pb.ioCompletion = NULL;
|
||||
pb.ioVolIndex = 0;
|
||||
pb.ioNamePtr = NULL;
|
||||
pb.ioVRefNum = mSpec.vRefNum;
|
||||
|
||||
OSErr err = PBHGetVInfoSync( (HParmBlkPtr)&pb );
|
||||
|
||||
if ( err == noErr )
|
||||
return pb.ioVFrBlk * pb.ioVAlBlkSiz;
|
||||
return ULONG_MAX;
|
||||
} // nsFileSpec::GetDiskSpace()
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
const char* nsFileSpec::GetCString() const
|
||||
// This is the only conversion to const char* that is provided, and it allows the
|
||||
// path to be "passed" to NSPR file routines. This practice is VERY EVIL and should only
|
||||
// be used to support legacy code. Using it guarantees bugs on Macintosh. The string is
|
||||
// cached and freed by the nsFileSpec destructor, so do not delete (or free) it.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mPath)
|
||||
{
|
||||
const_cast<nsFileSpec*>(this)->mPath
|
||||
= MacFileHelpers::PathNameFromFSSpec(mSpec, true);
|
||||
if (!mPath)
|
||||
const_cast<nsFileSpec*>(this)->mError = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return mPath;
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// Macintosh nsFilePath implementation
|
||||
//========================================================================================
|
||||
@@ -916,8 +804,8 @@ nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
|
||||
, mFileSpec(inString, inCreateDirs)
|
||||
{
|
||||
// Make canonical and absolute.
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -927,43 +815,29 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
|
||||
, mFileSpec(nsAutoCString(inString), inCreateDirs)
|
||||
{
|
||||
// Make canonical and absolute.
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsnull)
|
||||
: mFileSpec(inSpec)
|
||||
{
|
||||
*this = inSpec;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsnull)
|
||||
{
|
||||
*this = inOther.GetFileSpec();
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, true );
|
||||
delete [] mPath;
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
mFileSpec = inSpec;
|
||||
} // nsFilePath::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = inOther.GetFileSpec();
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsFileURL implementation
|
||||
//========================================================================================
|
||||
@@ -971,96 +845,35 @@ void nsFilePath::operator = (const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(nsFileSpecHelpers::StringDup(inString))
|
||||
{
|
||||
NS_ASSERTION(strstr(mURL, kFileURLPrefix) == mURL, "Not a URL!");
|
||||
mFileSpec.mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromUnixPath(
|
||||
mURL + kFileURLPrefixLength,
|
||||
mFileSpec.mSpec,
|
||||
true, // need to decode
|
||||
false, // don't resolve alias
|
||||
false, // must be a full path
|
||||
inCreateDirs));
|
||||
if (mFileSpec.mError == NS_FILE_RESULT(fnfErr))
|
||||
mFileSpec.mError = NS_OK;
|
||||
: mURL(nsnull)
|
||||
, mFileSpec(inString + kFileURLPrefixLength, inCreateDirs)
|
||||
{
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
|
||||
// Make canonical and absolute.
|
||||
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
||||
char* escapedPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
mURL = nsFileSpecHelpers::StringDup(kFileURLPrefix, kFileURLPrefixLength + strlen(escapedPath));
|
||||
strcat(mURL, escapedPath);
|
||||
delete [] escapedPath;
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(nsFileSpecHelpers::StringDup(nsAutoCString(inString)))
|
||||
{
|
||||
NS_ASSERTION(strstr(mURL, kFileURLPrefix) == mURL, "Not a URL!");
|
||||
mFileSpec.mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromUnixPath(
|
||||
mURL + kFileURLPrefixLength,
|
||||
mFileSpec.mSpec,
|
||||
true, // need to decode
|
||||
false, // don't resolve alias
|
||||
false, // must be a full path
|
||||
inCreateDirs));
|
||||
if (mFileSpec.mError == NS_FILE_RESULT(fnfErr))
|
||||
mFileSpec.mError = NS_OK;
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(nsnull)
|
||||
{
|
||||
*this = inOther.GetFileSpec();
|
||||
nsAutoCString aString(inString);
|
||||
const char* aCString = (const char*)aString;
|
||||
NS_ASSERTION(strstr(aCString, kFileURLPrefix) == aCString, "Not a URL!");
|
||||
mFileSpec = aCString + kFileURLPrefixLength;
|
||||
// Make canonical and absolute.
|
||||
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
||||
char* escapedPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
mURL = nsFileSpecHelpers::StringDup(kFileURLPrefix, kFileURLPrefixLength + strlen(escapedPath));
|
||||
strcat(mURL, escapedPath);
|
||||
delete [] escapedPath;
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFileSpec& inOther)
|
||||
: mURL(nsnull)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = inOther;
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = inOther.GetFileSpec();
|
||||
} // nsFileURL::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mFileSpec = inOther;
|
||||
delete [] mURL;
|
||||
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||
char* encodedPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
char* encodedURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, encodedPath);
|
||||
delete [] encodedPath;
|
||||
if (encodedURL[strlen(encodedURL) - 1] != '/' && inOther.IsDirectory())
|
||||
{
|
||||
mURL = nsFileSpecHelpers::AllocCat(encodedURL, "/");
|
||||
delete [] encodedURL;
|
||||
}
|
||||
else
|
||||
mURL = encodedURL;
|
||||
} // nsFileURL::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mURL, inString);
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
|
||||
mFileSpec.mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromUnixPath(
|
||||
inString + kFileURLPrefixLength,
|
||||
mFileSpec.mSpec,
|
||||
true, // need to decode
|
||||
false, // don't resolve alias
|
||||
false, // must be a full path
|
||||
false)); // don't create dirs.
|
||||
if (mFileSpec.mError == NS_FILE_RESULT(fnfErr))
|
||||
mFileSpec.mError = NS_OK;
|
||||
} // nsFileURL::operator =
|
||||
|
||||
//========================================================================================
|
||||
// nsDirectoryIterator
|
||||
//========================================================================================
|
||||
@@ -1075,15 +888,24 @@ nsDirectoryIterator::nsDirectoryIterator(
|
||||
, mIndex(-1)
|
||||
{
|
||||
CInfoPBRec pb;
|
||||
OSErr err = inDirectory.GetCatInfo(pb);
|
||||
|
||||
// test that we have got a directory back, not a file
|
||||
DirInfo* dipb = (DirInfo*)&pb;
|
||||
if (err != noErr || !( dipb->ioFlAttrib & 0x0010))
|
||||
// Sorry about this, there seems to be a bug in CWPro 4:
|
||||
const FSSpec& inSpec = inDirectory.nsFileSpec::operator const FSSpec&();
|
||||
Str255 outName;
|
||||
MacFileHelpers::PLstrcpy(outName, inSpec.name);
|
||||
pb.hFileInfo.ioNamePtr = outName;
|
||||
pb.hFileInfo.ioVRefNum = inSpec.vRefNum;
|
||||
pb.hFileInfo.ioDirID = inSpec.parID;
|
||||
pb.hFileInfo.ioFDirIndex = 0; // use ioNamePtr and ioDirID
|
||||
|
||||
OSErr err = PBGetCatInfoSync( &pb );
|
||||
|
||||
// test that we have got a directory back, not a file
|
||||
if ( (err != noErr ) || !( dipb->ioFlAttrib & 0x0010 ) )
|
||||
return;
|
||||
// Sorry about this, there seems to be a bug in CWPro 4:
|
||||
FSSpec& currentSpec = mCurrent.nsFileSpec::operator FSSpec&();
|
||||
currentSpec.vRefNum = currentSpec.vRefNum;
|
||||
currentSpec.vRefNum = inSpec.vRefNum;
|
||||
currentSpec.parID = dipb->ioDrDirID;
|
||||
mMaxIndex = pb.dirInfo.ioDrNmFls;
|
||||
if (inIterateDirection > 0)
|
||||
@@ -1147,4 +969,3 @@ nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
|
||||
}
|
||||
return *this;
|
||||
} // nsDirectoryIterator::operator ++
|
||||
|
||||
|
||||
@@ -133,7 +133,8 @@ class TimerPeriodical : public Repeater
|
||||
// TimerImpl implementation
|
||||
//========================================================================================
|
||||
|
||||
NS_IMPL_ISUPPORTS(TimerImpl, nsITimer::GetIID())
|
||||
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
|
||||
NS_IMPL_ISUPPORTS(TimerImpl, kITimerIID)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TimerImpl::TimerImpl()
|
||||
@@ -360,5 +361,5 @@ NS_BASE nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return timer->QueryInterface(nsITimer::GetIID(), (void **) aInstancePtrResult);
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
@@ -40,10 +40,8 @@ CPPSRCS = \
|
||||
nsVoidArray.cpp \
|
||||
nsFileSpec.cpp \
|
||||
nsFileStream.cpp \
|
||||
nsStringStream.cpp \
|
||||
nsEscape.cpp \
|
||||
nsIFileStream.cpp \
|
||||
nsSpecialSystemDirectory.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS = \
|
||||
@@ -65,8 +63,6 @@ CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsFileStream.obj \
|
||||
.\$(OBJDIR)\nsEscape.obj \
|
||||
.\$(OBJDIR)\nsIFileStream.obj \
|
||||
.\$(OBJDIR)\nsIStringStream.obj \
|
||||
.\$(OBJDIR)\nsSpecialSystemDirectory.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS=nscore.h nsIArena.h nsIAtom.h nsIByteBuffer.h \
|
||||
@@ -98,7 +94,7 @@ LCFLAGS = \
|
||||
# These are the libraries we need to link with to create the dll
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(LIBNSPR)
|
||||
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
|
||||
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib
|
||||
|
||||
@@ -36,10 +36,6 @@ public:
|
||||
|
||||
void* operator new(size_t size, const PRUnichar* us, PRInt32 uslen);
|
||||
|
||||
void operator delete(void* ptr) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
virtual void ToString(nsString& aBuf) const;
|
||||
|
||||
virtual const PRUnichar* GetUnicode() const;
|
||||
@@ -79,7 +75,7 @@ NS_IMPL_ISUPPORTS(AtomImpl, kIAtomIID);
|
||||
void* AtomImpl::operator new(size_t size, const PRUnichar* us, PRInt32 uslen)
|
||||
{
|
||||
size = size + uslen * sizeof(PRUnichar);
|
||||
AtomImpl* ii = (AtomImpl*) ::operator new(size);
|
||||
AtomImpl* ii = (AtomImpl*) new char[size];
|
||||
nsCRT::memcpy(ii->mString, us, uslen * sizeof(PRUnichar));
|
||||
ii->mString[uslen] = 0;
|
||||
return ii;
|
||||
|
||||
@@ -20,11 +20,7 @@
|
||||
#include "nscore.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsProperties.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
#include "nsRepository.h"
|
||||
|
||||
PRInt32 gLockCount = 0;
|
||||
|
||||
@@ -33,42 +29,28 @@ NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSRegisterSelf(nsISupports* aServMgr, const char* path)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult ret;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
ret = nsRepository::RegisterComponent(kPropertiesCID, NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kPropertiesCID, NULL, NULL,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSUnregisterSelf(nsISupports* aServMgr, const char* path)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult ret;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
ret = nsRepository::UnregisterFactory(kPropertiesCID, path);
|
||||
if (NS_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsIComponentManager* compMgr;
|
||||
rv = servMgr->GetService(kComponentManagerCID,
|
||||
nsIComponentManager::GetIID(),
|
||||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterFactory(kPropertiesCID, path);
|
||||
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
|
||||
@@ -56,7 +56,7 @@ NS_IMPL_ISUPPORTS(ByteBufferImpl,kByteBufferIID)
|
||||
ByteBufferImpl::~ByteBufferImpl()
|
||||
{
|
||||
if (nsnull != mBuffer) {
|
||||
delete[] mBuffer;
|
||||
delete mBuffer;
|
||||
mBuffer = nsnull;
|
||||
}
|
||||
mLength = 0;
|
||||
@@ -87,7 +87,7 @@ PRBool ByteBufferImpl::Grow(PRUint32 aNewSize)
|
||||
if (0 != mLength) {
|
||||
nsCRT::memcpy(newbuf, mBuffer, mLength);
|
||||
}
|
||||
delete[] mBuffer;
|
||||
delete mBuffer;
|
||||
mBuffer = newbuf;
|
||||
return PR_TRUE;
|
||||
}
|
||||
@@ -112,8 +112,9 @@ PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream,
|
||||
|
||||
// Read in some new data
|
||||
mLength = aKeep;
|
||||
PRUint32 amount = mSpace - aKeep;
|
||||
PRUint32 nb;
|
||||
*aErrorCode = aStream->Read(mBuffer + aKeep, mSpace - aKeep, &nb);
|
||||
*aErrorCode = aStream->Read(mBuffer, aKeep, amount, &nb);
|
||||
if (NS_SUCCEEDED(*aErrorCode)) {
|
||||
mLength += nb;
|
||||
}
|
||||
|
||||
@@ -198,16 +198,6 @@ PRUnichar nsCRT::ToLower(PRUnichar aChar)
|
||||
return TOLOWER(aChar);
|
||||
}
|
||||
|
||||
PRBool nsCRT::IsUpper(PRUnichar aChar)
|
||||
{
|
||||
return aChar != nsCRT::ToLower(aChar);
|
||||
}
|
||||
|
||||
PRBool nsCRT::IsLower(PRUnichar aChar)
|
||||
{
|
||||
return aChar != nsCRT::ToUpper(aChar);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// My lovely strtok routine
|
||||
|
||||
|
||||
@@ -187,10 +187,6 @@ public:
|
||||
static PRUnichar ToUpper(PRUnichar aChar);
|
||||
|
||||
static PRUnichar ToLower(PRUnichar aChar);
|
||||
|
||||
static PRBool IsUpper(PRUnichar aChar);
|
||||
|
||||
static PRBool IsLower(PRUnichar aChar);
|
||||
};
|
||||
|
||||
#endif /* nsCRT_h___ */
|
||||
|
||||
@@ -62,64 +62,45 @@ NS_BASE char* nsEscape(const char * str, nsEscapeMask mask)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_BASE char* nsEscapeCount(
|
||||
const char * str,
|
||||
PRInt32 len,
|
||||
nsEscapeMask mask,
|
||||
PRInt32* out_len)
|
||||
NS_BASE char* nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PRInt32 * out_len)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!str)
|
||||
return 0;
|
||||
int32 i, extra = 0;
|
||||
char *hexChars = "0123456789ABCDEF";
|
||||
|
||||
int i, extra = 0;
|
||||
char* hexChars = "0123456789ABCDEF";
|
||||
if(!str)
|
||||
return(0);
|
||||
|
||||
register const unsigned char* src = (const unsigned char *) str;
|
||||
register const unsigned char* src = (unsigned char *) str;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (!IS_OK(*src++))
|
||||
extra += 2; /* the escape, plus an extra byte for each nibble */
|
||||
}
|
||||
{
|
||||
if (!IS_OK(src[i]))
|
||||
extra+=2; /* the escape, plus an extra byte for each nibble */
|
||||
}
|
||||
|
||||
char* result = new char[len + extra + 1];
|
||||
if (!result)
|
||||
return 0;
|
||||
return(0);
|
||||
|
||||
register unsigned char* dst = (unsigned char *) result;
|
||||
src = (const unsigned char *) str;
|
||||
if (mask == url_XPAlphas)
|
||||
{
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
unsigned char c = *src++;
|
||||
if (IS_OK(c))
|
||||
*dst++ = c;
|
||||
else if (c == ' ')
|
||||
*dst++ = '+'; /* convert spaces to pluses */
|
||||
else
|
||||
{
|
||||
*dst++ = HEX_ESCAPE;
|
||||
*dst++ = hexChars[c >> 4]; /* high nibble */
|
||||
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
unsigned char c = *src++;
|
||||
if (IS_OK(c))
|
||||
*dst++ = c;
|
||||
else
|
||||
{
|
||||
*dst++ = HEX_ESCAPE;
|
||||
*dst++ = hexChars[c >> 4]; /* high nibble */
|
||||
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
unsigned char c = src[i];
|
||||
if (IS_OK(c))
|
||||
{
|
||||
*dst++ = c;
|
||||
}
|
||||
else if (mask == url_XPAlphas && c == ' ')
|
||||
{
|
||||
*dst++ = '+'; /* convert spaces to pluses */
|
||||
}
|
||||
else
|
||||
{
|
||||
*dst++ = HEX_ESCAPE;
|
||||
*dst++ = hexChars[c >> 4]; /* high nibble */
|
||||
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
||||
}
|
||||
}
|
||||
|
||||
*dst = '\0'; /* tack on eos */
|
||||
if(out_len)
|
||||
@@ -144,24 +125,27 @@ NS_BASE PRInt32 nsUnescapeCount(char * str)
|
||||
|
||||
while (*src)
|
||||
if (*src != HEX_ESCAPE)
|
||||
{
|
||||
*dst++ = *src++;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
src++; /* walk over escape */
|
||||
if (*src)
|
||||
{
|
||||
{
|
||||
*dst = UNHEX(*src) << 4;
|
||||
src++;
|
||||
}
|
||||
}
|
||||
if (*src)
|
||||
{
|
||||
{
|
||||
*dst = (*dst + UNHEX(*src));
|
||||
src++;
|
||||
}
|
||||
}
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
*dst = 0;
|
||||
|
||||
return (int)(dst - str);
|
||||
|
||||
} /* NET_UnEscapeCnt */
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "nsFileStream.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "plstr.h"
|
||||
@@ -188,7 +187,7 @@ char* nsFileSpecHelpers::GetLeaf(const char* inPath, char inSeparator)
|
||||
// So now, separator was the last character. Poke in a null instead.
|
||||
*(char*)lastSeparator = '\0'; // Should use const_cast, but Unix has old compiler.
|
||||
leafPointer = strrchr(inPath, inSeparator);
|
||||
char* result = leafPointer ? StringDup(++leafPointer) : StringDup(inPath);
|
||||
char* result = leafPointer ? StringDup(leafPointer++) : StringDup(inPath);
|
||||
// Restore the poked null before returning.
|
||||
*(char*)lastSeparator = inSeparator;
|
||||
#ifdef XP_PC
|
||||
@@ -226,33 +225,9 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
|
||||
char* currentEnd = strchr(currentStart + kSkipFirst, kSeparator);
|
||||
if (currentEnd)
|
||||
{
|
||||
nsFileSpec spec;
|
||||
|
||||
*currentEnd = '\0';
|
||||
|
||||
#ifdef XP_PC
|
||||
/*
|
||||
if we have a drive letter path, we must make sure that the inital path has a '/' on it, or
|
||||
Canonify will turn "/c|" into a path relative to the running executable.
|
||||
*/
|
||||
if (pathCopy[0] == '/' && pathCopy[2] == '|')
|
||||
{
|
||||
char* startDir = nsFileSpecHelpers::StringDup( pathCopy, (strlen(pathCopy) + 1) );
|
||||
strcat(startDir, "/");
|
||||
|
||||
spec = nsFilePath(startDir, PR_FALSE);
|
||||
|
||||
delete [] startDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
spec = nsFilePath(pathCopy, PR_FALSE);
|
||||
|
||||
}
|
||||
#else
|
||||
spec = nsFilePath(pathCopy, PR_FALSE);
|
||||
#endif
|
||||
do
|
||||
nsFileSpec spec(nsFilePath(pathCopy, PR_FALSE));
|
||||
do
|
||||
{
|
||||
// If the node doesn't exist, and it is not the initial node in a full path,
|
||||
// then make a directory (We cannot make the initial (volume) node).
|
||||
@@ -267,9 +242,6 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
|
||||
currentEnd = strchr(currentStart, kSeparator);
|
||||
if (!currentEnd)
|
||||
break;
|
||||
|
||||
*currentEnd = '\0';
|
||||
|
||||
spec += currentStart; // "lengthen" the path, adding the next node.
|
||||
} while (currentEnd);
|
||||
}
|
||||
@@ -342,25 +314,25 @@ nsFileURL::nsFileURL(const nsFileURL& inOther)
|
||||
{
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(nsnull)
|
||||
{
|
||||
*this = inOther;
|
||||
} // nsFileURL::nsFileURL
|
||||
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther))
|
||||
#ifdef XP_MAC
|
||||
, mFileSpec(inOther.GetFileSpec())
|
||||
#endif
|
||||
{
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFileSpec& inOther)
|
||||
: mURL(nsnull)
|
||||
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther)))
|
||||
#ifdef XP_MAC
|
||||
, mFileSpec(inOther)
|
||||
#endif
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = inOther;
|
||||
} // nsFileURL::nsFileURL
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::~nsFileURL()
|
||||
@@ -369,15 +341,16 @@ nsFileURL::~nsFileURL()
|
||||
delete [] mURL;
|
||||
}
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mURL, inString);
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
|
||||
} // nsFileURL::operator =
|
||||
#ifdef XP_MAC
|
||||
mFileSpec = inString + kFileURLPrefixLength;
|
||||
#endif
|
||||
} // nsFileURL::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFileURL& inOther)
|
||||
@@ -389,37 +362,28 @@ void nsFileURL::operator = (const nsFileURL& inOther)
|
||||
#endif
|
||||
} // nsFileURL::operator =
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
delete [] mURL;
|
||||
char* original = (char*)(const char*)inOther; // we shall modify, but restore.
|
||||
#ifdef XP_PC
|
||||
// because we don't want to escape the '|' character, change it to a letter.
|
||||
NS_ASSERTION(original[2] == '|', "No drive letter part!");
|
||||
original[2] = 'x';
|
||||
char* escapedPath = nsEscape(original, url_Path);
|
||||
original[2] = '|'; // restore it
|
||||
escapedPath[2] = '|';
|
||||
#else
|
||||
char* escapedPath = nsEscape(original, url_Path);
|
||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther);
|
||||
#ifdef XP_MAC
|
||||
mFileSpec = inOther.GetFileSpec();
|
||||
#endif
|
||||
if (escapedPath)
|
||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, escapedPath);
|
||||
delete [] escapedPath;
|
||||
} // nsFileURL::operator =
|
||||
#endif
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = nsFilePath(inOther);
|
||||
} // nsFileURL::operator =
|
||||
delete [] mURL;
|
||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther));
|
||||
#ifdef XP_MAC
|
||||
mFileSpec = inOther;
|
||||
#endif
|
||||
} // nsFileURL::operator =
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputStream& operator << (nsOutputStream& s, const nsFileURL& url)
|
||||
@@ -480,14 +444,15 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsFileSpecHelpers::StringDup(inOther.mURL + kFileURLPrefixLength))
|
||||
#ifdef XP_MAC
|
||||
, mFileSpec(inOther.GetFileSpec())
|
||||
#endif
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_UNIX
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -535,14 +500,15 @@ void nsFilePath::operator = (const char* inString)
|
||||
#endif // XP_MAC
|
||||
}
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, (const char*)nsFilePath(inOther));
|
||||
}
|
||||
#ifdef XP_MAC
|
||||
mFileSpec = inOther.GetFileSpec();
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsFilePath& inOther)
|
||||
@@ -571,7 +537,9 @@ nsFileSpec::nsFileSpec()
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec::nsFileSpec(const nsPersistentFileDescriptor& inDescriptor)
|
||||
//----------------------------------------------------------------------------------------
|
||||
#ifndef XP_MAC
|
||||
: mPath(nsnull)
|
||||
#endif
|
||||
{
|
||||
*this = inDescriptor;
|
||||
}
|
||||
@@ -579,7 +547,9 @@ nsFileSpec::nsFileSpec(const nsPersistentFileDescriptor& inDescriptor)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec::nsFileSpec(const nsFileURL& inURL)
|
||||
//----------------------------------------------------------------------------------------
|
||||
#ifndef XP_MAC
|
||||
: mPath(nsnull)
|
||||
#endif
|
||||
{
|
||||
*this = nsFilePath(inURL); // convert to unix path first
|
||||
}
|
||||
@@ -656,7 +626,6 @@ void nsFileSpec::operator = (const nsPersistentFileDescriptor& inDescriptor)
|
||||
Boolean changed;
|
||||
mError = NS_FILE_RESULT(::ResolveAlias(nsnull, aliasH, &mSpec, &changed));
|
||||
DisposeHandle((Handle) aliasH);
|
||||
delete [] mPath;
|
||||
#else
|
||||
nsFileSpecHelpers::StringAssign(mPath, (char*)data);
|
||||
mError = NS_OK;
|
||||
@@ -725,7 +694,9 @@ nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs)
|
||||
nsFileSpec::~nsFileSpec()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifndef XP_MAC
|
||||
delete [] mPath;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_PC)
|
||||
@@ -746,7 +717,7 @@ void nsFileSpec::operator = (const char* inString)
|
||||
{
|
||||
mPath = nsFileSpecHelpers::StringAssign(mPath, inString);
|
||||
// Make canonical and absolute.
|
||||
nsFileSpecHelpers::Canonify(mPath, PR_FALSE /* XXX? */);
|
||||
nsFileSpecHelpers::Canonify(mPath, PR_TRUE /* XXX? */);
|
||||
mError = NS_OK;
|
||||
}
|
||||
#endif //XP_UNIX
|
||||
@@ -756,17 +727,9 @@ void nsFileSpec::operator = (const char* inString)
|
||||
nsOutputStream& operator << (nsOutputStream& s, const nsFileSpec& spec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool warnedOnce = PR_FALSE;
|
||||
if (!warnedOnce)
|
||||
{
|
||||
NS_WARNING("This is for debugging only. Do not call this in shipped version!");
|
||||
warnedOnce = PR_TRUE;
|
||||
}
|
||||
#endif // NS_DEBUG
|
||||
return (s << spec.GetCString());
|
||||
return (s << (const char*)spec.mPath);
|
||||
}
|
||||
#endif // DEBUG ONLY!
|
||||
#endif // DEBUG && XP_UNIX
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec nsFileSpec::operator + (const char* inRelativePath) const
|
||||
@@ -777,57 +740,6 @@ nsFileSpec nsFileSpec::operator + (const char* inRelativePath) const
|
||||
return result;
|
||||
} // nsFileSpec::operator +
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRBool nsFileSpec::operator == (const nsFileSpec& inOther) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
#ifdef XP_MAC
|
||||
if ( inOther.mSpec.vRefNum == mSpec.vRefNum &&
|
||||
inOther.mSpec.parID == mSpec.parID &&
|
||||
EqualString(inOther.mSpec.name, mSpec.name, false, true))
|
||||
return PR_TRUE;
|
||||
#else
|
||||
PRBool amEmpty = !mPath || !*mPath;
|
||||
PRBool heEmpty = !inOther.mPath || !*inOther.mPath;
|
||||
if (amEmpty) // we're the same if he's empty...
|
||||
return heEmpty;
|
||||
if (heEmpty) // ('cuz I'm not...)
|
||||
return PR_FALSE;
|
||||
#if defined(XP_PC)
|
||||
// windows does not care about case.
|
||||
if (_stricmp(mPath, inOther.mPath ) == 0)
|
||||
return PR_TRUE;
|
||||
#else
|
||||
if (strcmp(mPath, inOther.mPath ) == 0)
|
||||
return PR_TRUE;
|
||||
#endif
|
||||
#endif
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRBool nsFileSpec::operator != (const nsFileSpec& inOther) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (! (*this == inOther) );
|
||||
}
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
const char* nsFileSpec::GetCString() const
|
||||
// This is the only automatic conversion to const char*
|
||||
// that is provided, and it allows the
|
||||
// path to be "passed" to NSPR file routines. This practice
|
||||
// is VERY EVIL and should only be used to support legacy
|
||||
// code. Using it guarantees bugs on Macintosh. The path is NOT allocated, so do
|
||||
// not even think of deleting (or freeing) it.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
//========================================================================================
|
||||
// class nsPersistentFileDescriptor
|
||||
//========================================================================================
|
||||
@@ -862,9 +774,13 @@ void nsPersistentFileDescriptor::operator = (const nsFileSpec& inSpec)
|
||||
if (inSpec.Error())
|
||||
return;
|
||||
AliasHandle aliasH;
|
||||
OSErr err = NewAlias(nil, inSpec.GetFSSpecPtr(), &aliasH);
|
||||
/*
|
||||
This is killing the tree. mcmullen will need to look at this.
|
||||
|
||||
OSErr err = NewAlias(nil, inSpec.operator const FSSpec* const (), &aliasH);
|
||||
if (err != noErr)
|
||||
return;
|
||||
*/
|
||||
|
||||
PRUint32 bytes = GetHandleSize((Handle) aliasH);
|
||||
HLock((Handle) aliasH);
|
||||
@@ -874,7 +790,7 @@ void nsPersistentFileDescriptor::operator = (const nsFileSpec& inSpec)
|
||||
nsFileSpecHelpers::StringAssign(mDescriptorString, buf);
|
||||
PR_Free(buf);
|
||||
#else
|
||||
nsFileSpecHelpers::StringAssign(mDescriptorString, inSpec.GetCString());
|
||||
nsFileSpecHelpers::StringAssign(mDescriptorString, inSpec);
|
||||
#endif // XP_MAC
|
||||
} // nsPersistentFileDescriptor::operator =
|
||||
|
||||
@@ -911,8 +827,7 @@ void nsPersistentFileDescriptor::SetData(const void* inData, PRInt32 inSize)
|
||||
nsresult nsPersistentFileDescriptor::Read(nsIInputStream* aStream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsInputStream inputStream(aStream);
|
||||
inputStream >> *this;
|
||||
nsInputStream(aStream) >> *this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -920,8 +835,7 @@ nsresult nsPersistentFileDescriptor::Read(nsIInputStream* aStream)
|
||||
nsresult nsPersistentFileDescriptor::Write(nsIOutputStream* aStream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsOutputStream outputStream(aStream);
|
||||
outputStream << *this;
|
||||
nsOutputStream(aStream) << *this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -937,7 +851,7 @@ nsInputStream& operator >> (nsInputStream& s, nsPersistentFileDescriptor& d)
|
||||
if (bytesRead != 8)
|
||||
return s;
|
||||
bigBuffer[8] = '\0';
|
||||
sscanf(bigBuffer, "%lx", (PRUint32*)&bytesRead);
|
||||
sscanf(bigBuffer, "%lx", &bytesRead);
|
||||
if (bytesRead > MAX_PERSISTENT_DATA_SIZE)
|
||||
return s; // preposterous.
|
||||
// Now we know how many bytes to read, do it.
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "nsFileStream.h"
|
||||
|
||||
#include "nsIStringStream.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@@ -47,19 +46,6 @@ char nsInputStream::get()
|
||||
return c;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRInt32 nsInputStream::read(void* s, PRInt32 n)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mInputStream)
|
||||
return 0;
|
||||
PRInt32 result = 0;
|
||||
mInputStream->Read((char*)s, n, (PRUint32*)&result);
|
||||
if (result < n)
|
||||
set_at_eof(PR_TRUE);
|
||||
return result;
|
||||
} // nsInputStream::read
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
static void TidyEndOfLine(char*& cp)
|
||||
// Assumes that cp is pointing at \n or \r. Nulls out the character, checks for
|
||||
@@ -98,17 +84,6 @@ void nsOutputStream::put(char c)
|
||||
write(&c, sizeof(c));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRInt32 nsOutputStream::write(const void* s, PRInt32 n)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mOutputStream)
|
||||
return 0;
|
||||
PRInt32 result = 0;
|
||||
mOutputStream->Write((char*)s, n, (PRUint32*)&result);
|
||||
return result;
|
||||
} // nsOutputStream::write
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsOutputStream::flush()
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -136,7 +111,7 @@ nsOutputStream& nsOutputStream::operator << (short val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%hd", val);
|
||||
sprintf(buf, "%d", val);
|
||||
return (*this << buf);
|
||||
}
|
||||
|
||||
@@ -145,7 +120,7 @@ nsOutputStream& nsOutputStream::operator << (unsigned short val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%hu", val);
|
||||
sprintf(buf, "%ud", val);
|
||||
return (*this << buf);
|
||||
}
|
||||
|
||||
@@ -163,34 +138,16 @@ nsOutputStream& nsOutputStream::operator << (unsigned long val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%lu", val);
|
||||
return (*this << buf);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputStream& nsOutputStream::operator << (int val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%d", val);
|
||||
return (*this << buf);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputStream& nsOutputStream::operator << (unsigned int val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%u", val);
|
||||
sprintf(buf, "%uld", val);
|
||||
return (*this << buf);
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsRandomAccessInputStream
|
||||
// nsInputFileStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRBool nsRandomAccessInputStream::readline(char* s, PRInt32 n)
|
||||
PRBool nsInputFileStream::readline(char* s, PRInt32 n)
|
||||
// This will truncate if the buffer is too small. Result will always be null-terminated.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
@@ -216,84 +173,7 @@ PRBool nsRandomAccessInputStream::readline(char* s, PRInt32 n)
|
||||
position += bytesRead;
|
||||
seek(position);
|
||||
return bufferLargeEnough;
|
||||
} // nsRandomAccessInputStream::readline
|
||||
|
||||
//========================================================================================
|
||||
// nsInputStringStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsInputStringStream::nsInputStringStream(const char* stringToRead)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsISupports* stream;
|
||||
if (NS_FAILED(NS_NewCharInputStream(&stream, stringToRead)))
|
||||
return;
|
||||
mInputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
NS_RELEASE(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsInputStringStream::nsInputStringStream(const nsString& stringToRead)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsISupports* stream;
|
||||
if (NS_FAILED(NS_NewStringInputStream(&stream, stringToRead)))
|
||||
return;
|
||||
mInputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
NS_RELEASE(stream);
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsOutputStringStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputStringStream::nsOutputStringStream(char*& stringToChange)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsISupports* stream;
|
||||
if (NS_FAILED(NS_NewCharOutputStream(&stream, &stringToChange)))
|
||||
return;
|
||||
mOutputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
NS_RELEASE(stream);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputStringStream::nsOutputStringStream(nsString& stringToChange)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsISupports* stream;
|
||||
if (NS_FAILED(NS_NewStringOutputStream(&stream, stringToChange)))
|
||||
return;
|
||||
mOutputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
NS_RELEASE(stream);
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsInputFileStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsInputFileStream::nsInputFileStream(
|
||||
const nsFileSpec& inFile,
|
||||
int nsprMode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsISupports* stream;
|
||||
if (NS_FAILED(NS_NewIOFileStream(&stream, inFile, nsprMode, accessMode)))
|
||||
return;
|
||||
mFile = nsQueryInterface(stream);
|
||||
mInputStream = nsQueryInterface(stream);
|
||||
mStore = nsQueryInterface(stream);
|
||||
mFileInputStream = nsQueryInterface(stream);
|
||||
NS_RELEASE(stream);
|
||||
} // nsInputFileStream::nsInputFileStream
|
||||
} // nsInputStream::readline
|
||||
|
||||
//========================================================================================
|
||||
// nsOutputFileStream
|
||||
|
||||
@@ -35,7 +35,7 @@ class nsISizeOfHandler;
|
||||
*/
|
||||
class nsIAtom : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IATOM_IID; return iid; }
|
||||
static const nsIID& IID() { static nsIID iid = NS_IATOM_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Translate the unicode string into the stringbuf.
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
class nsIBaseStream : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IBASESTREAM_IID; return iid; }
|
||||
static const nsIID& IID() { static nsIID iid = NS_IBASESTREAM_IID; return iid; }
|
||||
|
||||
/** Close the stream. */
|
||||
NS_IMETHOD
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
//========================================================================================
|
||||
class FileImpl
|
||||
: public nsIRandomAccessStore
|
||||
: public nsIOutputStream
|
||||
, public nsIInputStream
|
||||
, public nsIFileOutputStream
|
||||
, public nsIFileInputStream
|
||||
, public nsIFile
|
||||
@@ -77,6 +78,7 @@ class FileImpl
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD Read(char* aBuf,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount)
|
||||
{
|
||||
@@ -90,6 +92,8 @@ class FileImpl
|
||||
return NS_FILE_RESULT(PR_BAD_DESCRIPTOR_ERROR);
|
||||
if (mFailed)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aOffset)
|
||||
PR_Seek(mFileDesc, aOffset, PR_SEEK_CUR);
|
||||
PRInt32 bytesRead = PR_Read(mFileDesc, aBuf, aCount);
|
||||
if (bytesRead < 0)
|
||||
{
|
||||
@@ -102,6 +106,7 @@ class FileImpl
|
||||
}
|
||||
// nsIOutputStream interface
|
||||
NS_IMETHOD Write(const char* aBuf,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aWriteCount)
|
||||
{
|
||||
@@ -122,8 +127,10 @@ class FileImpl
|
||||
return NS_FILE_RESULT(PR_BAD_DESCRIPTOR_ERROR);
|
||||
if (mFailed)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aOffset)
|
||||
PR_Seek(mFileDesc, aOffset, PR_SEEK_CUR);
|
||||
PRInt32 bytesWrit = PR_Write(mFileDesc, aBuf, aCount);
|
||||
if (bytesWrit != (PRInt32)aCount)
|
||||
if (bytesWrit != aCount)
|
||||
{
|
||||
mFailed = PR_TRUE;
|
||||
*aWriteCount = 0;
|
||||
@@ -147,19 +154,19 @@ class FileImpl
|
||||
|
||||
protected:
|
||||
|
||||
PRFileDesc* mFileDesc;
|
||||
int mNSPRMode;
|
||||
PRBool mFailed;
|
||||
PRBool mEOF;
|
||||
PRInt32 mLength;
|
||||
PRFileDesc* mFileDesc;
|
||||
int mNSPRMode;
|
||||
PRBool mFailed;
|
||||
PRBool mEOF;
|
||||
PRInt32 mLength;
|
||||
}; // class FileImpl
|
||||
|
||||
#define SAY_I_IMPLEMENT(classname) \
|
||||
if (aIID.Equals(classname::GetIID())) \
|
||||
{ \
|
||||
#define SAY_I_IMPLEMENT(classname) \
|
||||
if (aIID.Equals(classname::IID())) \
|
||||
{ \
|
||||
*aInstancePtr = (void*)((classname*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
NS_IMPL_RELEASE(FileImpl)
|
||||
@@ -175,7 +182,6 @@ NS_IMETHODIMP FileImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
*aInstancePtr = nsnull;
|
||||
|
||||
SAY_I_IMPLEMENT(nsIFile)
|
||||
SAY_I_IMPLEMENT(nsIRandomAccessStore)
|
||||
SAY_I_IMPLEMENT(nsIOutputStream)
|
||||
SAY_I_IMPLEMENT(nsIInputStream)
|
||||
SAY_I_IMPLEMENT(nsIFileInputStream)
|
||||
@@ -184,13 +190,13 @@ NS_IMETHODIMP FileImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
// of nsISupports), one through
|
||||
// nsIOutputStream, the other through nsIInputStream. Resolve this
|
||||
// by giving them a specific one
|
||||
if (aIID.Equals(((nsIBaseStream*)(nsIOutputStream*)this)->GetIID()))
|
||||
if (aIID.Equals(((nsIBaseStream*)(nsIOutputStream*)this)->IID()))
|
||||
{
|
||||
*aInstancePtr = (void*)((nsIBaseStream*)(nsIOutputStream*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(((nsISupports*)(nsIOutputStream*)this)->GetIID()))
|
||||
if (aIID.Equals(((nsISupports*)(nsIOutputStream*)this)->IID()))
|
||||
{
|
||||
*aInstancePtr = (void*)((nsISupports*)(nsIOutputStream*)this);
|
||||
NS_ADDREF_THIS();
|
||||
@@ -301,7 +307,7 @@ NS_IMETHODIMP FileImpl::Seek(PRSeekWhence whence, PRInt32 offset)
|
||||
PRInt32 position = PR_Seek(mFileDesc, 0, PR_SEEK_CUR);
|
||||
PRInt32 available = PR_Available(mFileDesc);
|
||||
PRInt32 fileSize = position + available;
|
||||
PRInt32 newPosition = 0;
|
||||
PRInt32 newPosition;
|
||||
switch (whence)
|
||||
{
|
||||
case PR_SEEK_CUR: newPosition = position + offset; break;
|
||||
@@ -313,7 +319,7 @@ NS_IMETHODIMP FileImpl::Seek(PRSeekWhence whence, PRInt32 offset)
|
||||
newPosition = 0;
|
||||
mFailed = PR_TRUE;
|
||||
}
|
||||
if (newPosition >= fileSize) // nb: not "else if".
|
||||
else if (newPosition >= fileSize)
|
||||
{
|
||||
newPosition = fileSize;
|
||||
mEOF = PR_TRUE;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
class nsIInputStream : public nsIBaseStream {
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IINPUTSTREAM_IID; return iid; }
|
||||
static const nsIID& IID() { static nsIID iid = NS_IINPUTSTREAM_IID; return iid; }
|
||||
|
||||
/** Return the number of bytes in the stream
|
||||
* @param aLength out parameter to hold the length
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
/** Read data from the stream.
|
||||
* @param aErrorCode the error code if an error occurs
|
||||
* @param aBuf the buffer into which the data is read
|
||||
* @param aOffset the start offset of the data
|
||||
* @param aCount the maximum number of bytes to read
|
||||
* @param aReadCount out parameter to hold the number of
|
||||
* bytes read, eof if 0. if an error occurs, the
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount) = 0;
|
||||
Read(char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aReadCount) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsInputStream_h___ */
|
||||
|
||||
@@ -29,10 +29,11 @@
|
||||
class nsIOutputStream : public nsIBaseStream {
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IOUTPUTSTREAM_IID; return iid; }
|
||||
static const nsIID& IID() { static nsIID iid = NS_IOUTPUTSTREAM_IID; return iid; }
|
||||
|
||||
/** Write data into the stream.
|
||||
* @param aBuf the buffer into which the data is read
|
||||
* @param aOffset the start offset of the data
|
||||
* @param aCount the maximum number of bytes to read
|
||||
* @param aWriteCount out parameter to hold the number of
|
||||
* bytes written. if an error occurs, the writecount
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount) = 0;
|
||||
Write(const char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aWriteCount) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,463 +0,0 @@
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIFileStream.h"
|
||||
|
||||
#include "prerror.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "plstr.h"
|
||||
|
||||
//========================================================================================
|
||||
class BasicStringImpl
|
||||
: public nsIOutputStream
|
||||
, public nsIInputStream
|
||||
, public nsIRandomAccessStore
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
BasicStringImpl()
|
||||
: mResult(NS_OK)
|
||||
, mEOF(PR_FALSE)
|
||||
, mOffset(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
virtual ~BasicStringImpl()
|
||||
{
|
||||
}
|
||||
NS_IMETHOD Seek(PRSeekWhence whence, PRInt32 offset);
|
||||
|
||||
NS_IMETHOD Tell(PRIntn* outWhere)
|
||||
{
|
||||
*outWhere = mOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetAtEOF(PRBool* outAtEOF)
|
||||
{
|
||||
*outAtEOF = mEOF;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD SetAtEOF(PRBool inAtEOF)
|
||||
{
|
||||
mEOF = inAtEOF;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32 *aLength)
|
||||
{
|
||||
NS_PRECONDITION(aLength != nsnull, "null ptr");
|
||||
if (!aLength)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aLength = length();
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD Read(char* aBuf,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount)
|
||||
{
|
||||
NS_PRECONDITION(aBuf != nsnull, "null ptr");
|
||||
if (!aBuf)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
NS_PRECONDITION(aReadCount != nsnull, "null ptr");
|
||||
if (!aReadCount)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (NS_FAILED(mResult))
|
||||
return mResult;
|
||||
PRInt32 bytesRead = read(aBuf, aCount);
|
||||
if (NS_FAILED(mResult))
|
||||
{
|
||||
*aReadCount = 0;
|
||||
return mResult;
|
||||
}
|
||||
*aReadCount = bytesRead;
|
||||
if (bytesRead < aCount)
|
||||
SetAtEOF(PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
// nsIOutputStream interface
|
||||
NS_IMETHOD Write(const char* aBuf,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aWriteCount)
|
||||
{
|
||||
NS_PRECONDITION(aBuf != nsnull, "null ptr");
|
||||
NS_PRECONDITION(aWriteCount != nsnull, "null ptr");
|
||||
|
||||
if (NS_FAILED(mResult))
|
||||
return mResult;
|
||||
PRInt32 bytesWrit = write(aBuf, aCount);
|
||||
if (NS_FAILED(mResult))
|
||||
{
|
||||
*aWriteCount = 0;
|
||||
return mResult;
|
||||
}
|
||||
*aWriteCount = bytesWrit;
|
||||
return NS_OK;
|
||||
}
|
||||
public:
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Close() { return NS_OK; }
|
||||
|
||||
// nsIInputStream interface
|
||||
NS_IMETHOD Flush() { return NS_OK; }
|
||||
|
||||
|
||||
public:
|
||||
nsresult get_result() const { return mResult; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRInt32 length() const = 0;
|
||||
virtual PRInt32 read(char* buf, PRUint32 count) = 0;
|
||||
virtual PRInt32 write(const char*, PRUint32)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "Write to a const string");
|
||||
mResult = NS_FILE_RESULT(PR_ILLEGAL_ACCESS_ERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
PRUint32 mOffset;
|
||||
nsresult mResult;
|
||||
PRBool mEOF;
|
||||
}; // class BasicStringImpl
|
||||
|
||||
//========================================================================================
|
||||
class ConstCharImpl
|
||||
: public BasicStringImpl
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
ConstCharImpl(const char* inString)
|
||||
: mConstString(inString)
|
||||
, mLength(inString ? strlen(inString) : 0)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRInt32 length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
virtual PRInt32 read(char* buf, PRUint32 aCount)
|
||||
{
|
||||
PRInt32 maxCount = mLength - mOffset;
|
||||
if (aCount > maxCount)
|
||||
aCount = maxCount;
|
||||
memcpy(buf, mConstString + mOffset, aCount);
|
||||
mOffset += aCount;
|
||||
return aCount;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
const char* mConstString;
|
||||
size_t mLength;
|
||||
|
||||
}; // class ConstCharImpl
|
||||
|
||||
//========================================================================================
|
||||
class CharImpl
|
||||
: public ConstCharImpl
|
||||
//========================================================================================
|
||||
{
|
||||
enum { kAllocQuantum = 256 };
|
||||
|
||||
public:
|
||||
CharImpl(char** inString)
|
||||
: ConstCharImpl(*inString)
|
||||
, mString(*inString)
|
||||
, mAllocLength(mLength + 1)
|
||||
, mOriginalLength(mLength)
|
||||
{
|
||||
if (!mString)
|
||||
{
|
||||
mAllocLength += kAllocQuantum;
|
||||
mString = new char[mAllocLength];
|
||||
if (!mString)
|
||||
{
|
||||
mResult = NS_ERROR_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
mConstString = mString;
|
||||
*mString = '\0';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
virtual PRInt32 write(const char* buf, PRUint32 aCount)
|
||||
{
|
||||
PRInt32 maxCount = mAllocLength - 1 - mOffset;
|
||||
if (aCount > maxCount)
|
||||
{
|
||||
|
||||
do {
|
||||
maxCount += kAllocQuantum;
|
||||
} while (aCount > maxCount);
|
||||
mAllocLength = maxCount + 1 + mOffset;
|
||||
char* newString = new char[mAllocLength];
|
||||
if (!newString)
|
||||
{
|
||||
mResult = NS_ERROR_OUT_OF_MEMORY;
|
||||
return 0;
|
||||
}
|
||||
strcpy(newString, mString);
|
||||
delete [] mString;
|
||||
mString = newString;
|
||||
mConstString = newString;
|
||||
}
|
||||
memcpy(mString + mOffset, buf, aCount);
|
||||
mOffset += aCount;
|
||||
if (mOffset > mOriginalLength)
|
||||
mString[mOffset] = 0;
|
||||
return aCount;
|
||||
}
|
||||
protected:
|
||||
|
||||
char*& mString;
|
||||
size_t mOriginalLength;
|
||||
size_t mAllocLength;
|
||||
|
||||
}; // class CharImpl
|
||||
|
||||
//========================================================================================
|
||||
class ConstStringImpl
|
||||
: public ConstCharImpl
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
ConstStringImpl(const nsString& inString)
|
||||
: ConstCharImpl(inString.ToNewCString())
|
||||
{
|
||||
}
|
||||
|
||||
~ConstStringImpl()
|
||||
{
|
||||
delete [] (char*)mConstString;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
|
||||
}; // class ConstStringImpl
|
||||
|
||||
|
||||
//========================================================================================
|
||||
class StringImpl
|
||||
: public ConstStringImpl
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
StringImpl(nsString& inString)
|
||||
: ConstStringImpl(inString)
|
||||
, mString(inString)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRInt32 write(const char* buf, PRUint32 count)
|
||||
{
|
||||
// Clone our string as chars
|
||||
char* cstring = mString.ToNewCString();
|
||||
// Make a CharImpl and do the write
|
||||
CharImpl chars(&cstring);
|
||||
chars.Seek(PR_SEEK_SET, mOffset);
|
||||
// Get the bytecount and result from the CharImpl
|
||||
PRInt32 result = chars.write(buf,count);
|
||||
mResult = chars.get_result();
|
||||
// Set our string to match the new chars
|
||||
mString = cstring;
|
||||
// Set our const string also...
|
||||
delete [] (char*)mConstString;
|
||||
mConstString = cstring;
|
||||
return result;
|
||||
}
|
||||
protected:
|
||||
|
||||
nsString& mString;
|
||||
|
||||
}; // class StringImpl
|
||||
|
||||
#define SAY_I_IMPLEMENT(classname) \
|
||||
if (aIID.Equals(classname::GetIID())) \
|
||||
{ \
|
||||
*aInstancePtr = (void*)((classname*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
NS_IMPL_RELEASE(BasicStringImpl)
|
||||
NS_IMPL_ADDREF(BasicStringImpl)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP BasicStringImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstancePtr = nsnull;
|
||||
|
||||
SAY_I_IMPLEMENT(nsIRandomAccessStore)
|
||||
SAY_I_IMPLEMENT(nsIOutputStream)
|
||||
SAY_I_IMPLEMENT(nsIInputStream)
|
||||
// Note that we derive from two copies of nsIBaseStream (and hence
|
||||
// of nsISupports), one through
|
||||
// nsIOutputStream, the other through nsIInputStream. Resolve this
|
||||
// by giving them a specific one
|
||||
if (aIID.Equals(((nsIBaseStream*)(nsIOutputStream*)this)->GetIID()))
|
||||
{
|
||||
*aInstancePtr = (void*)((nsIBaseStream*)(nsIOutputStream*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(((nsISupports*)(nsIOutputStream*)this)->GetIID()))
|
||||
{
|
||||
*aInstancePtr = (void*)((nsISupports*)(nsIOutputStream*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
} // StringImpl::QueryInterface
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP BasicStringImpl::Seek(PRSeekWhence whence, PRInt32 offset)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mResult = NS_OK; // reset on a seek.
|
||||
mEOF = PR_FALSE; // reset on a seek.
|
||||
PRInt32 fileSize = length();
|
||||
PRInt32 newPosition;
|
||||
switch (whence)
|
||||
{
|
||||
case PR_SEEK_CUR: newPosition = mOffset + offset; break;
|
||||
case PR_SEEK_SET: newPosition = offset; break;
|
||||
case PR_SEEK_END: newPosition = fileSize + offset; break;
|
||||
}
|
||||
if (newPosition < 0)
|
||||
{
|
||||
newPosition = 0;
|
||||
mResult = NS_FILE_RESULT(PR_FILE_SEEK_ERROR);
|
||||
}
|
||||
if (newPosition >= fileSize)
|
||||
{
|
||||
newPosition = fileSize;
|
||||
mEOF = PR_TRUE;
|
||||
}
|
||||
mOffset = newPosition;
|
||||
return NS_OK;
|
||||
} // StringImpl::Seek
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewStringInputStream(
|
||||
nsISupports** aStreamResult,
|
||||
const nsString& aStringToRead)
|
||||
// Factory method to get an nsInputStream from a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
|
||||
if (! aStreamResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
ConstStringImpl* stream = new ConstStringImpl(aStringToRead);
|
||||
if (! stream)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(stream);
|
||||
*aStreamResult = (nsISupports*)(void*)stream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewStringOutputStream(
|
||||
nsISupports** aStreamResult,
|
||||
nsString& aStringToChange)
|
||||
// Factory method to get an nsOutputStream from a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
|
||||
if (! aStreamResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
StringImpl* stream = new StringImpl(aStringToChange);
|
||||
if (! stream)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(stream);
|
||||
*aStreamResult = (nsISupports*)(void*)stream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewCharInputStream(
|
||||
nsISupports** aStreamResult,
|
||||
const char* aStringToRead)
|
||||
// Factory method to get an nsInputStream from a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
|
||||
if (! aStreamResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
ConstCharImpl* stream = new ConstCharImpl(aStringToRead);
|
||||
if (! stream)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(stream);
|
||||
*aStreamResult = (nsISupports*)(void*)stream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewCharOutputStream(
|
||||
nsISupports** aStreamResult,
|
||||
char** aStringToChange)
|
||||
// Factory method to get an nsOutputStream to a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
|
||||
NS_PRECONDITION(aStringToChange != nsnull, "null ptr");
|
||||
if (!aStreamResult || !aStringToChange)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
CharImpl* stream = new CharImpl(aStringToChange);
|
||||
if (! stream)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(stream);
|
||||
*aStreamResult = (nsISupports*)(void*)stream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewStringIOStream(
|
||||
nsISupports** aStreamResult,
|
||||
nsString& aStringToChange)
|
||||
// Factory method to get an nsOutputStream to a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return NS_NewStringOutputStream(aStreamResult, aStringToChange);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
extern "C" NS_BASE nsresult NS_NewCharIOStream(
|
||||
nsISupports** aStreamResult,
|
||||
char** aStringToChange)
|
||||
// Factory method to get an nsOutputStream to a string. Result will implement all the
|
||||
// file stream interfaces in nsIFileStream.h
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return NS_NewCharOutputStream(aStreamResult, aStringToChange);
|
||||
}
|
||||
@@ -45,8 +45,6 @@ typedef void
|
||||
*/
|
||||
class nsITimer : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITIMER_IID)
|
||||
|
||||
/**
|
||||
* Initialize a timer to fire after the given millisecond interval.
|
||||
* This version takes a function to call and a closure to pass to
|
||||
|
||||
@@ -35,9 +35,7 @@ class nsITimer;
|
||||
*/
|
||||
class nsITimerCallback : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITIMERCALLBACK_IID)
|
||||
|
||||
virtual void Notify(nsITimer *timer) = 0;
|
||||
virtual void Notify(nsITimer *timer)=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,7 @@ nsProperties::nsProperties()
|
||||
mTable = nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRIntn)
|
||||
PR_CALLBACK PRIntn
|
||||
FreeHashEntries(PLHashEntry* he, PRIntn i, void* arg)
|
||||
{
|
||||
delete[] (PRUnichar*)he->key;
|
||||
|
||||
@@ -1,369 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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.
|
||||
*
|
||||
* Contributors:
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Folders.h>
|
||||
#include <Files.h>
|
||||
#include <Memory.h>
|
||||
#include <Processes.h>
|
||||
#elif defined(XP_PC)
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#elif defined(XP_UNIX)
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "plstr.h"
|
||||
|
||||
#if XP_PC
|
||||
//----------------------------------------------------------------------------------------
|
||||
static char* MakeUpperCase(char* aPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// windows does not care about case. push to uppercase:
|
||||
int length = strlen(aPath);
|
||||
for (int i = 0; i < length; i++)
|
||||
if (islower(aPath[i]))
|
||||
aPath[i] = _toupper(aPath[i]);
|
||||
|
||||
return aPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
static void GetCurrentProcessDirectory(nsFileSpec& aFileSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifdef XP_PC
|
||||
char buf[MAX_PATH];
|
||||
if ( ::GetModuleFileName(0, buf, sizeof(buf)) ) {
|
||||
// chop of the executable name by finding the rightmost backslash
|
||||
char* lastSlash = PL_strrchr(buf, '\\');
|
||||
if (lastSlash)
|
||||
*(lastSlash + 1) = '\0';
|
||||
|
||||
aFileSpec = buf;
|
||||
return;
|
||||
}
|
||||
|
||||
#elif defined(XP_MAC)
|
||||
// get info for the the current process to determine the directory
|
||||
// its located in
|
||||
OSErr err;
|
||||
ProcessSerialNumber psn;
|
||||
if (!(err = GetCurrentProcess(&psn)))
|
||||
{
|
||||
ProcessInfoRec pInfo;
|
||||
FSSpec tempSpec;
|
||||
|
||||
// initialize ProcessInfoRec before calling
|
||||
// GetProcessInformation() or die horribly.
|
||||
pInfo.processName = nil;
|
||||
pInfo.processAppSpec = &tempSpec;
|
||||
pInfo.processInfoLength = sizeof(ProcessInfoRec);
|
||||
|
||||
if (!(err = GetProcessInformation(&psn, &pInfo)))
|
||||
{
|
||||
FSSpec appFSSpec = *(pInfo.processAppSpec);
|
||||
long theDirID = appFSSpec.parID;
|
||||
|
||||
Str255 name;
|
||||
CInfoPBRec catInfo;
|
||||
catInfo.dirInfo.ioCompletion = NULL;
|
||||
catInfo.dirInfo.ioNamePtr = (StringPtr)&name;
|
||||
catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum;
|
||||
catInfo.dirInfo.ioDrDirID = theDirID;
|
||||
catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID
|
||||
|
||||
if (!(err = PBGetCatInfoSync(&catInfo)))
|
||||
{
|
||||
aFileSpec = nsFileSpec(appFSSpec.vRefNum,
|
||||
catInfo.dirInfo.ioDrParID,
|
||||
name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
|
||||
// In the absence of a good way to get the executable directory let
|
||||
// us try this for unix:
|
||||
// - if MOZILLA_FIVE_HOME is defined, that is it
|
||||
// - else give the current directory
|
||||
char buf[MAXPATHLEN];
|
||||
char *moz5 = getenv("MOZILLA_FIVE_HOME");
|
||||
if (moz5)
|
||||
{
|
||||
aFileSpec = moz5;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getcwd(buf, sizeof(buf)))
|
||||
{
|
||||
aFileSpec = buf;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NS_ERROR("unable to get current process directory");
|
||||
}
|
||||
|
||||
//nsSpecialSystemDirectory::nsSpecialSystemDirectory()
|
||||
//: nsFileSpec(nsnull)
|
||||
//{
|
||||
//}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsSpecialSystemDirectory::nsSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: nsFileSpec(nsnull)
|
||||
{
|
||||
*this = aSystemSystemDirectory;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsSpecialSystemDirectory::~nsSpecialSystemDirectory()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirectory)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = (const char*)nsnull;
|
||||
switch (aSystemSystemDirectory)
|
||||
{
|
||||
|
||||
case OS_DriveDirectory:
|
||||
#ifdef XP_PC
|
||||
{
|
||||
char path[_MAX_PATH];
|
||||
PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
|
||||
if (len)
|
||||
{
|
||||
if ( path[1] == ':' && path[2] == '\\' )
|
||||
path[3] = 0;
|
||||
}
|
||||
*this = MakeUpperCase(path);
|
||||
}
|
||||
#elif defined(XP_MAC)
|
||||
{
|
||||
*this = kVolumeRootFolderType;
|
||||
}
|
||||
#else
|
||||
*this = "/";
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
||||
case OS_TemporaryDirectory:
|
||||
#ifdef XP_PC
|
||||
char path[_MAX_PATH];
|
||||
if ( GetEnvironmentVariable(TEXT("TMP"), path, _MAX_PATH) == 0 )
|
||||
if (GetEnvironmentVariable(TEXT("TEMP"), path, _MAX_PATH))
|
||||
{
|
||||
// still not set!
|
||||
PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
|
||||
if (len)
|
||||
{
|
||||
strcat( path, "temp" );
|
||||
}
|
||||
}
|
||||
|
||||
strcat( path, "\\" );
|
||||
*this = MakeUpperCase(path);
|
||||
#elif defined(XP_MAC)
|
||||
*this = kTemporaryFolderType;
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
*this = "/tmp/";
|
||||
#endif
|
||||
break;
|
||||
|
||||
case OS_CurrentProcessDirectory:
|
||||
GetCurrentProcessDirectory(*this);
|
||||
break;
|
||||
|
||||
#ifdef XP_MAC
|
||||
case Mac_SystemDirectory:
|
||||
*this = kSystemFolderType;
|
||||
break;
|
||||
|
||||
case Mac_DesktopDirectory:
|
||||
*this = kDesktopFolderType;
|
||||
break;
|
||||
|
||||
case Mac_TrashDirectory:
|
||||
*this = kTrashFolderType;
|
||||
break;
|
||||
|
||||
case Mac_StartupDirectory:
|
||||
*this = kStartupFolderType;
|
||||
break;
|
||||
|
||||
case Mac_ShutdownDirectory:
|
||||
*this = kShutdownFolderType;
|
||||
break;
|
||||
|
||||
case Mac_AppleMenuDirectory:
|
||||
*this = kAppleMenuFolderType;
|
||||
break;
|
||||
|
||||
case Mac_ControlPanelDirectory:
|
||||
*this = kControlPanelFolderType;
|
||||
break;
|
||||
|
||||
case Mac_ExtensionDirectory:
|
||||
*this = kExtensionFolderType;
|
||||
break;
|
||||
|
||||
case Mac_FontsDirectory:
|
||||
*this = kFontsFolderType;
|
||||
break;
|
||||
|
||||
case Mac_PreferencesDirectory:
|
||||
*this = kPreferencesFolderType;
|
||||
break;
|
||||
|
||||
case Mac_DocumentsDirectory:
|
||||
*this = kDocumentsFolderType;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef XP_PC
|
||||
case Win_SystemDirectory:
|
||||
{
|
||||
char path[_MAX_PATH];
|
||||
PRInt32 len = GetSystemDirectory( path, _MAX_PATH );
|
||||
|
||||
// Need enough space to add the trailing backslash
|
||||
if (len > _MAX_PATH-2)
|
||||
break;
|
||||
path[len] = '\\';
|
||||
path[len+1] = '\0';
|
||||
|
||||
*this = MakeUpperCase(path);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Win_WindowsDirectory:
|
||||
{
|
||||
char path[_MAX_PATH];
|
||||
PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
|
||||
|
||||
// Need enough space to add the trailing backslash
|
||||
if (len > _MAX_PATH-2)
|
||||
break;
|
||||
|
||||
path[len] = '\\';
|
||||
path[len+1] = '\0';
|
||||
|
||||
*this = MakeUpperCase(path);
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef XP_UNIX
|
||||
case Unix_LocalDirectory:
|
||||
*this = "/usr/local/netscape/";
|
||||
break;
|
||||
|
||||
case Unix_LibDirectory:
|
||||
*this = "/usr/local/lib/netscape/";
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsSpecialSystemDirectory::nsSpecialSystemDirectory(OSType folderType)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = folderType;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsSpecialSystemDirectory::operator = (OSType folderType)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CInfoPBRec cinfo;
|
||||
DirInfo *dipb=(DirInfo *)&cinfo;
|
||||
|
||||
// Call FindFolder to fill in the vrefnum and dirid
|
||||
for (int attempts = 0; attempts < 2; attempts++)
|
||||
{
|
||||
mError = NS_FILE_RESULT(
|
||||
FindFolder(
|
||||
kOnSystemDisk,
|
||||
folderType,
|
||||
true,
|
||||
&dipb->ioVRefNum,
|
||||
&dipb->ioDrDirID));
|
||||
if (NS_SUCCEEDED(mError))
|
||||
break;
|
||||
if (attempts > 0)
|
||||
return;
|
||||
switch (folderType)
|
||||
{
|
||||
case kDocumentsFolderType:
|
||||
// Find folder will find this, as long as it exists.
|
||||
// The "create" parameter, however, is sadly ignored.
|
||||
// How do we internationalize this?
|
||||
*this = kVolumeRootFolderType;
|
||||
*this += "Documents";
|
||||
CreateDirectory();
|
||||
break;
|
||||
} // switch
|
||||
} // for
|
||||
StrFileName filename;
|
||||
filename[0] = '\0';
|
||||
dipb->ioNamePtr = (StringPtr)&filename;
|
||||
dipb->ioFDirIndex = -1;
|
||||
|
||||
mError = NS_FILE_RESULT(PBGetCatInfoSync(&cinfo));
|
||||
if (NS_SUCCEEDED(mError))
|
||||
{
|
||||
mError = NS_FILE_RESULT(FSMakeFSSpec(dipb->ioVRefNum, dipb->ioDrParID, filename, &mSpec));
|
||||
}
|
||||
}
|
||||
#endif // XP_MAC
|
||||
@@ -148,7 +148,7 @@ static void CheckCaseConversion()
|
||||
if(NULL == gCaseConv )
|
||||
StartUpCaseConversion();
|
||||
|
||||
// NS_ASSERTION( gCaseConv != NULL , "cannot obtain UnicharUtil");
|
||||
NS_ASSERTION( gCaseConv != NULL , "cannot obtain UnicharUtil");
|
||||
|
||||
}
|
||||
|
||||
@@ -489,11 +489,9 @@ void nsString::ToLowerCase()
|
||||
{
|
||||
// I18N code begin
|
||||
CheckCaseConversion();
|
||||
if(gCaseConv) {
|
||||
nsresult err = gCaseConv->ToLower(mStr, mStr, mLength);
|
||||
if( NS_SUCCEEDED(err))
|
||||
return;
|
||||
}
|
||||
nsresult err = gCaseConv->ToLower(mStr, mStr, mLength);
|
||||
if( NS_SUCCEEDED(err))
|
||||
return;
|
||||
// I18N code end
|
||||
|
||||
// somehow UnicharUtil return failed, fallback to the old ascii only code
|
||||
@@ -516,11 +514,9 @@ void nsString::ToUpperCase()
|
||||
{
|
||||
// I18N code begin
|
||||
CheckCaseConversion();
|
||||
if(gCaseConv) {
|
||||
nsresult err = gCaseConv->ToUpper(mStr, mStr, mLength);
|
||||
if( NS_SUCCEEDED(err))
|
||||
return;
|
||||
}
|
||||
nsresult err = gCaseConv->ToUpper(mStr, mStr, mLength);
|
||||
if( NS_SUCCEEDED(err))
|
||||
return;
|
||||
// I18N code end
|
||||
|
||||
// somehow UnicharUtil return failed, fallback to the old ascii only code
|
||||
@@ -566,12 +562,10 @@ void nsString::ToLowerCase(nsString& aOut) const
|
||||
|
||||
// I18N code begin
|
||||
CheckCaseConversion();
|
||||
if(gCaseConv) {
|
||||
nsresult err = gCaseConv->ToLower(mStr, aOut.mStr, mLength);
|
||||
(*(aOut.mStr+mLength)) = 0;
|
||||
if( NS_SUCCEEDED(err))
|
||||
return;
|
||||
}
|
||||
nsresult err = gCaseConv->ToLower(mStr, aOut.mStr, mLength);
|
||||
(*(aOut.mStr+mLength)) = 0;
|
||||
if( NS_SUCCEEDED(err))
|
||||
return;
|
||||
// I18N code end
|
||||
|
||||
// somehow UnicharUtil return failed, fallback to the old ascii only code
|
||||
@@ -602,12 +596,10 @@ void nsString::ToUpperCase(nsString& aOut) const
|
||||
|
||||
// I18N code begin
|
||||
CheckCaseConversion();
|
||||
if(gCaseConv) {
|
||||
nsresult err = gCaseConv->ToUpper(mStr, aOut.mStr, mLength);
|
||||
(*(aOut.mStr+mLength)) = 0;
|
||||
if( NS_SUCCEEDED(err))
|
||||
return;
|
||||
}
|
||||
nsresult err = gCaseConv->ToUpper(mStr, aOut.mStr, mLength);
|
||||
(*(aOut.mStr+mLength)) = 0;
|
||||
if( NS_SUCCEEDED(err))
|
||||
return;
|
||||
// I18N code end
|
||||
|
||||
// somehow UnicharUtil return failed, fallback to the old ascii only code
|
||||
@@ -1700,7 +1692,7 @@ PRInt32 nsString::RFind(const char* anAsciiSet,PRBool aIgnoreCase) const{
|
||||
*/
|
||||
PRInt32 nsString::RFind(PRUnichar aChar,PRBool aIgnoreCase) const{
|
||||
chartype uc=nsCRT::ToUpper(aChar);
|
||||
for(PRInt32 offset=mLength-1;offset>=0;offset--)
|
||||
for(PRInt32 offset=mLength-1;offset>0;offset--)
|
||||
if(aIgnoreCase) {
|
||||
if(nsCRT::ToUpper(mStr[offset])==uc)
|
||||
return offset;
|
||||
|
||||
@@ -56,7 +56,7 @@ NS_IMPL_ISUPPORTS(UnicharBufferImpl,kUnicharBufferIID)
|
||||
UnicharBufferImpl::~UnicharBufferImpl()
|
||||
{
|
||||
if (nsnull != mBuffer) {
|
||||
delete[] mBuffer;
|
||||
delete mBuffer;
|
||||
mBuffer = nsnull;
|
||||
}
|
||||
mLength = 0;
|
||||
@@ -87,7 +87,7 @@ PRBool UnicharBufferImpl::Grow(PRInt32 aNewSize)
|
||||
if (0 != mLength) {
|
||||
nsCRT::memcpy(newbuf, mBuffer, mLength * sizeof(PRUnichar));
|
||||
}
|
||||
delete[] mBuffer;
|
||||
delete mBuffer;
|
||||
mBuffer = newbuf;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
@@ -164,5 +164,8 @@ typedef PRUcs2 PRUnichar;
|
||||
// No sense in making an NS_DYNAMIC_CAST() macro: you can't duplicate
|
||||
// the semantics. So if you want to dynamic_cast, then just use it
|
||||
// "straight", no macro.
|
||||
#if defined(AIX)
|
||||
#define explicit
|
||||
#endif
|
||||
|
||||
#endif /* nscore_h___ */
|
||||
|
||||
@@ -25,42 +25,9 @@
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include "nsError.h"
|
||||
|
||||
#if defined(IRIX) || defined(OSF1) || defined(SOLARIS) || defined(UNIXWARE) || defined(SNI) || defined(NCR) || defined(NEC) || defined(DGUX)
|
||||
#include <sys/statvfs.h> /* for statvfs() */
|
||||
#define STATFS statvfs
|
||||
#elif defined(SCO_SV)
|
||||
#define _SVID3/* for statvfs.h */
|
||||
#include <sys/statvfs.h> /* for statvfs() */
|
||||
#define STATFS statvfs
|
||||
#elif defined(HPUX)
|
||||
#include <sys/vfs.h> /* for statfs() */
|
||||
#define STATFS statfs
|
||||
#elif defined(LINUX)
|
||||
#include <sys/vfs.h> /* for statfs() */
|
||||
#define STATFS statfs
|
||||
#elif defined(SUNOS4)
|
||||
#include <sys/vfs.h> /* for statfs() */
|
||||
extern "C" int statfs(char *, struct statfs *);
|
||||
#define STATFS statfs
|
||||
#else
|
||||
#if defined(BSDI) || defined(NETBSD) || defined(OPENBSD) || defined(RHAPSODY) || defined(FREEBSD)
|
||||
#include <sys/mount.h>/* for statfs() */
|
||||
#define STATFS statfs
|
||||
#else
|
||||
#include <sys/statfs.h> /* for statfs() */
|
||||
#define STATFS statfs
|
||||
extern "C" int statfs(char *, struct statfs *);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(OSF1)
|
||||
extern "C" int statvfs(const char *, struct statvfs *);
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpecHelpers::Canonify(char*& ioPath, PRBool inMakeDirs)
|
||||
// Canonify, make absolute, and check whether directories exist
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -131,27 +98,6 @@ PRBool nsFileSpec::Exists() const
|
||||
return 0 == stat(mPath, &st);
|
||||
} // nsFileSpec::Exists
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpec::GetModDate(TimeStamp& outStamp) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(mPath, &st) == 0)
|
||||
outStamp = st.st_mtime;
|
||||
else
|
||||
outStamp = 0;
|
||||
} // nsFileSpec::GetModDate
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint32 nsFileSpec::GetFileSize() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(mPath, &st) == 0)
|
||||
return (PRUint32)st.st_size;
|
||||
return 0;
|
||||
} // nsFileSpec::GetFileSize
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRBool nsFileSpec::IsFile() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -304,14 +250,12 @@ nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
|
||||
if (inParentDirectory.IsDirectory() && (! IsDirectory() ) )
|
||||
{
|
||||
char *leafname = GetLeafName();
|
||||
char* destPath = nsFileSpecHelpers::StringDup(
|
||||
inParentDirectory.GetCString(),
|
||||
strlen(inParentDirectory.GetCString()) + 1 + strlen(leafname));
|
||||
char* destPath = nsFileSpecHelpers::StringDup(inParentDirectory, ( strlen(inParentDirectory) + 1 + strlen(leafname) ) );
|
||||
strcat(destPath, "/");
|
||||
strcat(destPath, leafname);
|
||||
delete [] leafname;
|
||||
|
||||
result = NS_FILE_RESULT(CrudeFileCopy(GetCString(), destPath));
|
||||
result = NS_FILE_RESULT(CrudeFileCopy(*this, destPath));
|
||||
|
||||
delete [] destPath;
|
||||
}
|
||||
@@ -330,13 +274,13 @@ nsresult nsFileSpec::Move(const nsFileSpec& inNewParentDirectory) const
|
||||
char *leafname = GetLeafName();
|
||||
char* destPath
|
||||
= nsFileSpecHelpers::StringDup(
|
||||
inNewParentDirectory.GetCString(),
|
||||
strlen(inNewParentDirectory.GetCString()) + 1 + strlen(leafname));
|
||||
inNewParentDirectory,
|
||||
strlen(inNewParentDirectory) + 1 + strlen(leafname));
|
||||
strcat(destPath, "/");
|
||||
strcat(destPath, leafname);
|
||||
delete [] leafname;
|
||||
|
||||
result = NS_FILE_RESULT(CrudeFileCopy(GetCString(), destPath));
|
||||
result = NS_FILE_RESULT(CrudeFileCopy(*this, destPath));
|
||||
if (result == NS_OK)
|
||||
{
|
||||
// cast to fix const-ness
|
||||
@@ -368,31 +312,6 @@ nsresult nsFileSpec::Execute(const char* inArgs ) const
|
||||
|
||||
} // nsFileSpec::Execute
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char curdir [MAXPATHLEN];
|
||||
if (!mPath || !*mPath)
|
||||
{
|
||||
(void) getcwd(curdir, MAXPATHLEN);
|
||||
if (!curdir)
|
||||
return ULONG_MAX; /* hope for the best as we did in cheddar */
|
||||
}
|
||||
else
|
||||
sprintf(curdir, "%.200s", mPath);
|
||||
|
||||
struct STATFS fs_buf;
|
||||
if (STATFS(curdir, &fs_buf) < 0)
|
||||
return ULONG_MAX; /* hope for the best as we did in cheddar */
|
||||
|
||||
#ifdef DEBUG_DISK_SPACE
|
||||
printf("DiskSpaceAvailable: %d bytes\n",
|
||||
fs_buf.f_bsize * (fs_buf.f_bavail - 1));
|
||||
#endif
|
||||
return fs_buf.f_bsize * (fs_buf.f_bavail - 1);
|
||||
} // nsFileSpec::GetDiskSpace()
|
||||
|
||||
//========================================================================================
|
||||
// nsDirectoryIterator
|
||||
//========================================================================================
|
||||
@@ -400,7 +319,7 @@ PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator::nsDirectoryIterator(
|
||||
const nsFileSpec& inDirectory
|
||||
, int /*inIterateDirection*/)
|
||||
, int inIterateDirection)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mCurrent(inDirectory)
|
||||
, mExists(PR_FALSE)
|
||||
|
||||
@@ -29,7 +29,7 @@ nsCaretProperties::nsCaretProperties()
|
||||
, mBlinkRate(eDefaulBlinkRate)
|
||||
{
|
||||
// in your platform-specific class, get data from the OS in your constructor
|
||||
mCaretWidth = 30; // 2 pixel caret on Windows
|
||||
mCaretWidth = 2; // 2 pixel caret on Windows
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <direct.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include "prio.h"
|
||||
#include "nsError.h"
|
||||
@@ -42,15 +41,13 @@ void nsFileSpecHelpers::Canonify(char*& ioPath, PRBool inMakeDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!ioPath)
|
||||
return;
|
||||
|
||||
if (inMakeDirs)
|
||||
{
|
||||
const int mode = 0700;
|
||||
char* unixStylePath = nsFileSpecHelpers::StringDup(ioPath);
|
||||
nsFileSpecHelpers::NativeToUnix(unixStylePath);
|
||||
nsFileSpecHelpers::MakeAllDirectories(unixStylePath, mode);
|
||||
delete[] unixStylePath;
|
||||
return;
|
||||
if (inMakeDirs) {
|
||||
const int mode = 0700;
|
||||
char* unixStylePath = nsFileSpecHelpers::StringDup(ioPath);
|
||||
nsFileSpecHelpers::NativeToUnix(unixStylePath);
|
||||
nsFileSpecHelpers::MakeAllDirectories(unixStylePath, mode);
|
||||
delete[] unixStylePath;
|
||||
}
|
||||
char buffer[_MAX_PATH];
|
||||
errno = 0;
|
||||
@@ -59,7 +56,7 @@ void nsFileSpecHelpers::Canonify(char*& ioPath, PRBool inMakeDirs)
|
||||
|
||||
NS_ASSERTION( canonicalPath[0] != '\0', "Uh oh...couldn't convert" );
|
||||
if (canonicalPath[0] == '\0')
|
||||
return;
|
||||
return;
|
||||
|
||||
nsFileSpecHelpers::StringAssign(ioPath, canonicalPath);
|
||||
}
|
||||
@@ -191,27 +188,6 @@ PRBool nsFileSpec::Exists() const
|
||||
return 0 == stat(mPath, &st);
|
||||
} // nsFileSpec::Exists
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpec::GetModDate(TimeStamp& outStamp) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(mPath, &st) == 0)
|
||||
outStamp = st.st_mtime;
|
||||
else
|
||||
outStamp = 0;
|
||||
} // nsFileSpec::GetModDate
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint32 nsFileSpec::GetFileSize() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(mPath, &st) == 0)
|
||||
return (PRUint32)st.st_size;
|
||||
return 0;
|
||||
} // nsFileSpec::GetFileSize
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRBool nsFileSpec::IsFile() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -249,12 +225,7 @@ void nsFileSpec::operator += (const char* inRelativePath)
|
||||
nsFileSpecHelpers::ReallocCat(mPath, "x");
|
||||
else
|
||||
nsFileSpecHelpers::ReallocCat(mPath, "\\x");
|
||||
|
||||
// If it's a (unix) relative path, make it native
|
||||
char* dosPath = nsFileSpecHelpers::StringDup(inRelativePath);
|
||||
nsFileSpecHelpers::UnixToNative(dosPath);
|
||||
SetLeafName(dosPath);
|
||||
delete [] dosPath;
|
||||
SetLeafName(inRelativePath);
|
||||
} // nsFileSpec::operator +=
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@@ -386,49 +357,6 @@ nsresult nsFileSpec::Execute(const char* inArgs ) const
|
||||
return NS_FILE_FAILURE;
|
||||
} // nsFileSpec::Execute
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char aDrive[_MAX_DRIVE + 2];
|
||||
_splitpath( mPath, aDrive, NULL, NULL, NULL);
|
||||
|
||||
if (aDrive[0] == '\0')
|
||||
{
|
||||
// The back end is always trying to pass us paths that look
|
||||
// like /c|/netscape/mail. See if we've got one of them
|
||||
if (strlen(mPath) > 2 && mPath[0] == '/' && mPath[2] == '|')
|
||||
{
|
||||
aDrive[0] = mPath[1];
|
||||
aDrive[1] = ':';
|
||||
aDrive[2] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return bogus large number and hope for the best
|
||||
return ULONG_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
strcat(aDrive, "\\");
|
||||
|
||||
DWORD dwSectorsPerCluster = 0;
|
||||
DWORD dwBytesPerSector = 0;
|
||||
DWORD dwFreeClusters = 0;
|
||||
DWORD dwTotalClusters = 0;
|
||||
if (!GetDiskFreeSpace(aDrive,
|
||||
&dwSectorsPerCluster,
|
||||
&dwBytesPerSector,
|
||||
&dwFreeClusters,
|
||||
&dwTotalClusters))
|
||||
{
|
||||
return ULONG_MAX; // Return bogus large number and hope for the best
|
||||
}
|
||||
|
||||
// We can now figure free disk space.
|
||||
return dwFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
|
||||
} // nsFileSpec::GetDiskSpaceAvailable()
|
||||
|
||||
//========================================================================================
|
||||
// nsDirectoryIterator
|
||||
//========================================================================================
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,7 +42,7 @@ LIBS = \
|
||||
$(TK_LIBS) \
|
||||
-lpref \
|
||||
-lsecfree \
|
||||
-l$(MOZ_LIB_JS_PREFIX)js \
|
||||
-ljs \
|
||||
-lxp \
|
||||
-lraptorbase \
|
||||
-lxpcom \
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "nsIProperties.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsRepository.h"
|
||||
#ifdef XP_PC
|
||||
#include "plevent.h"
|
||||
#endif
|
||||
@@ -60,9 +60,9 @@ extern "C" void NS_SetupRegistry();
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL,
|
||||
nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL,
|
||||
PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL,
|
||||
nsRepository::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL,
|
||||
PR_FALSE, PR_FALSE);
|
||||
#ifdef XP_MAC // have not build this on PC and UNIX yet so make it #ifdef XP_MAC
|
||||
NS_SetupRegistry();
|
||||
@@ -102,7 +102,7 @@ main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
nsIProperties *props = nsnull;
|
||||
ret = nsComponentManager::CreateInstance(kPropertiesCID, NULL,
|
||||
ret = nsRepository::CreateInstance(kPropertiesCID, NULL,
|
||||
kIPropertiesIID, (void**) &props);
|
||||
if (NS_FAILED(ret)) {
|
||||
printf("create nsIProperties failed\n");
|
||||
|
||||
@@ -45,7 +45,7 @@ LLIBS= \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
!endif
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
|
||||
$(GLOWDIR)\glowcode.lib \
|
||||
!endif
|
||||
|
||||
@@ -29,7 +29,6 @@ dnl MOZ_ARG_ENABLE_BOOL_OR_STRING( NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
|
||||
dnl MOZ_ARG_WITH_BOOL( NAME, HELP, IF-YES [, IF-NO [, ELSE])
|
||||
dnl MOZ_ARG_WITHOUT_BOOL( NAME, HELP, IF-NO [, IF-YES [, ELSE])
|
||||
dnl MOZ_ARG_WITH_STRING( NAME, HELP, IF-SET [, ELSE])
|
||||
dnl MOZ_ARG_HEADER(Comment)
|
||||
dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
|
||||
|
||||
|
||||
@@ -87,18 +86,24 @@ dnl MOZ_ARG_WITH_STRING(NAME, HELP, IF-SET [, ELSE])
|
||||
AC_DEFUN(MOZ_ARG_WITH_STRING,
|
||||
[AC_ARG_WITH([$1], [$2], [$3], [$4])])
|
||||
|
||||
dnl MOZ_ARG_HEADER(Comment)
|
||||
dnl This is used by webconfig to group options
|
||||
define(MOZ_ARG_HEADER, [# $1])
|
||||
|
||||
|
||||
dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
|
||||
AC_DEFUN(MOZ_READ_MOZCONFIG,
|
||||
AC_DEFUN(MOZ_READ_MYCONFIG,
|
||||
[AC_REQUIRE([AC_INIT_BINSH])dnl
|
||||
# Read in 'mozconfig.sh' script to set the initial options.
|
||||
# See the load-mozconfig.sh script for more details.
|
||||
TOPSRCDIR=`dirname [$]0`
|
||||
PATH="$TOPSRCDIR/build/autoconf:$PATH"
|
||||
. load-mozconfig.sh])
|
||||
# Read in 'myconfig.sh' script to set the initial options.
|
||||
# See the load-myconfig.sh script for more details.
|
||||
_topsrcdir=`dirname [$]0`
|
||||
_load_myconfig=$_topsrcdir/build/autoconf/load-myconfig.sh
|
||||
if test "$MOZ_MYCONFIG"; then
|
||||
. $_load_myconfig
|
||||
elif test -f myconfig.sh; then
|
||||
MOZ_MYCONFIG=myconfig.sh
|
||||
. $_load_myconfig
|
||||
elif test -f $_topsrcdir/myconfig.sh; then
|
||||
MOZ_MYCONFIG=$_topsrcdir/myconfig.sh
|
||||
. $_load_myconfig
|
||||
fi])
|
||||
|
||||
dnl This gets inserted at the top of the configure script
|
||||
MOZ_READ_MOZCONFIG
|
||||
MOZ_READ_MYCONFIG
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
# clean-config.sh - Removes all files generated by mozilla configure.
|
||||
# Only removes files from the topsrcdir. To clean up an objdir,
|
||||
# simply remove the directory and start over.
|
||||
#
|
||||
# Usage:
|
||||
# 1. cd <topsrcdir>
|
||||
# 2. build/autoconf/clean-config.sh
|
||||
#
|
||||
# Send comments, improvements, bugs to slamm@netscape.com
|
||||
|
||||
topsrcdir=`cd \`dirname $0\`/../..; pwd`
|
||||
|
||||
if [ ! -f configure.in ]; then
|
||||
echo "clean-config.sh only cleans the source tree. To run," 2>&1
|
||||
echo " cd $topsrcdir; build/autoconf/clean-config.sh" 2>&1
|
||||
echo " (To clean a separate objdir, simple remove the directory.)" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MOZ_EDITOR=1 MOZ_MAILNEWS=1 . allmakefiles.sh
|
||||
rm -fr $MAKEFILES \
|
||||
config-defs.h \
|
||||
config.cache \
|
||||
config.log \
|
||||
config.status \
|
||||
$NULL
|
||||
|
||||
echo "Removed all files generated by configure." 2>&1
|
||||
3
mozilla/build/autoconf/config.guess
vendored
3
mozilla/build/autoconf/config.guess
vendored
@@ -749,9 +749,6 @@ EOF
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
*:QNX:*:*)
|
||||
echo i386-pc-qnx`${UNAME_VERSION} | cut -c1-1`
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
|
||||
10
mozilla/build/autoconf/config.sub
vendored
10
mozilla/build/autoconf/config.sub
vendored
@@ -143,10 +143,6 @@ case $os in
|
||||
-psos*)
|
||||
os=-psos
|
||||
;;
|
||||
-qnx*)
|
||||
basic_machine=i386-pc
|
||||
os=-qnx`uname -v | cut -c1-1`
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decode aliases for certain CPU-COMPANY combinations.
|
||||
@@ -509,10 +505,6 @@ case $basic_machine in
|
||||
ps2)
|
||||
basic_machine=i386-ibm
|
||||
;;
|
||||
*qnx*)
|
||||
basic_machine=i386-pc
|
||||
os=-qnx`uname -v | cut -c1-1`
|
||||
;;
|
||||
rm[46]00)
|
||||
basic_machine=mips-siemens
|
||||
;;
|
||||
@@ -783,8 +775,6 @@ case $os in
|
||||
-xenix)
|
||||
os=-xenix
|
||||
;;
|
||||
-qnx*)
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
# find-mozconfig.sh - Loads options from mozconfig.sh onto configure's
|
||||
# command-line. The mozconfig.sh file is searched for in the
|
||||
# order:
|
||||
# if $MOZCONFIG is set, use that.
|
||||
# Otherwise, use $TOPSRCDIR/mozconfig.sh
|
||||
# Otherwise, use $HOME/.mozconfig.sh
|
||||
#
|
||||
topsrcdir=`cd \`dirname $0\`/../..; pwd`
|
||||
|
||||
for _config in $MOZCONFIG \
|
||||
$MOZ_MYCONFIG \
|
||||
$topsrcdir/mozconfig \
|
||||
$topsrcdir/mozconfig.sh \
|
||||
$topsrcdir/myconfig.sh \
|
||||
$HOME/.mozconfig \
|
||||
$HOME/.mozconfig.sh \
|
||||
$HOME/.mozmyconfig.sh
|
||||
do
|
||||
if test -f $_config; then
|
||||
echo $_config;
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
@@ -16,15 +16,15 @@
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
# load-mozconfig.sh - Loads options from mozconfig.sh onto configure's
|
||||
# command-line. See find-mozconfig.sh for how the config file is
|
||||
# found
|
||||
# load-myconfig.sh - Loads options from myconfig.sh onto configure's
|
||||
# command-line. The myconfig.sh is searched for in the following
|
||||
# order: $MOZ_MYCONFIG, $objdir/myconfig.sh, $topsrcdir/myconfig.sh.
|
||||
#
|
||||
# The options from mozconfig.sh are inserted into the command-line
|
||||
# The options from myconfig.sh are inserted into the command-line
|
||||
# before the real command-line options. This way the real options
|
||||
# will override any mozconfig.sh options.
|
||||
# will override any myconfig.sh options.
|
||||
#
|
||||
# mozconfig.sh is a shell script. To add an option to configure's
|
||||
# myconfig.sh is a shell script. To add an option to configure's
|
||||
# command-line use the pre-defined function, ac_add_options,
|
||||
#
|
||||
# ac_add_options <configure-option> [<configure-option> ... ]
|
||||
@@ -33,7 +33,7 @@
|
||||
#
|
||||
# ac_add_options --with-pthreads --enable-debug
|
||||
#
|
||||
# ac_add_options can be called multiple times in mozconfig.sh.
|
||||
# ac_add_options can be called multiple times in myconfig.sh.
|
||||
# Each call adds more options to configure's command-line.
|
||||
#
|
||||
# Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
|
||||
@@ -43,29 +43,18 @@ ac_add_options() {
|
||||
for _opt
|
||||
do
|
||||
# Escape shell characters, space, tab, dollar, quote, backslash.
|
||||
_opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;s/@\([^@]*\)@/\$\1/g;'`
|
||||
_opt=`echo $_opt | sed -e 's/@\([^@]*\)@/\$(\1)/g'`
|
||||
_opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;'`
|
||||
|
||||
# Avoid adding duplicates
|
||||
case "$ac_options" in
|
||||
*"$_opt"* ) ;;
|
||||
* ) mozconfig_ac_options="$mozconfig_ac_options $_opt" ;;
|
||||
esac
|
||||
config_file_options="$config_file_options $_opt"
|
||||
done
|
||||
}
|
||||
|
||||
mk_add_options() {
|
||||
# These options are for client.mk
|
||||
# configure can safely ignore them.
|
||||
:
|
||||
}
|
||||
|
||||
ac_echo_options() {
|
||||
echo "Adding options from $MOZCONFIG:"
|
||||
eval "set -- $mozconfig_ac_options"
|
||||
for _opt
|
||||
echo "Adding options from `pwd`/myconfig.sh:"
|
||||
eval "set -- $config_file_options"
|
||||
for opt
|
||||
do
|
||||
echo " $_opt"
|
||||
echo " $opt"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -73,7 +62,7 @@ ac_echo_options() {
|
||||
# Define load the options
|
||||
#
|
||||
ac_options=
|
||||
mozconfig_ac_options=
|
||||
config_file_options=
|
||||
|
||||
# Save the real command-line options
|
||||
for _opt
|
||||
@@ -84,14 +73,9 @@ do
|
||||
ac_options="$ac_options \"$_opt\""
|
||||
done
|
||||
|
||||
# Call find-mozconfig.sh
|
||||
# In params: $MOZCONFIG $HOME (old:$MOZ_MYCONFIG)
|
||||
MOZCONFIG=`$TOPSRCDIR/build/autoconf/find-mozconfig.sh`
|
||||
. $MOZ_MYCONFIG
|
||||
|
||||
if [ "$MOZCONFIG" ]; then
|
||||
. $MOZCONFIG
|
||||
ac_echo_options 1>&2
|
||||
fi
|
||||
ac_echo_options 1>&2
|
||||
|
||||
eval "set -- $mozconfig_ac_options $ac_options"
|
||||
eval "set -- $config_file_options $ac_options"
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# This script will match a dir with a set of dirs.
|
||||
#
|
||||
# Usage: match-dir.sh match [dir1 dir2 ... dirn]
|
||||
#
|
||||
# Send comments, improvements, bugs to ramiro@netscape.com
|
||||
#
|
||||
|
||||
# Make sure a Makefile.in exists
|
||||
#if [ $# -lt 1 ]
|
||||
#then
|
||||
# echo
|
||||
# echo "Usage: `basename $0` match [dir1 dir2 ... dirn]"
|
||||
# echo
|
||||
#
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
# Make sure a Makefile.in exists
|
||||
if [ ! -f Makefile.in ]
|
||||
then
|
||||
echo
|
||||
echo "There ain't no 'Makefile.in' over here: $pwd, dude."
|
||||
echo
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use DEPTH in the Makefile.in to determine the depth
|
||||
depth=`grep -w DEPTH Makefile.in | grep -e "\.\." | awk -F"=" '{ print $2; }'`
|
||||
|
||||
# Determine the depth count
|
||||
n=`echo $depth | tr '/' ' ' | wc -w`
|
||||
|
||||
# Determine the path (strip anything before the mozilla/ root)
|
||||
path=`pwd | awk -v count=$n -F"/" '\
|
||||
{ for(i=NF-count+0; i <= NF ; i++) \
|
||||
{ \
|
||||
if (i!=NF) \
|
||||
{ printf "%s/", $i } \
|
||||
else \
|
||||
{ printf "%s", $i } \
|
||||
} \
|
||||
}'`
|
||||
|
||||
match=$path
|
||||
|
||||
for i in $*
|
||||
do
|
||||
# echo "Looking for $match in $i"
|
||||
|
||||
echo $i | grep -q -x $match
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "1"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# echo "Looking for $i in $match"
|
||||
|
||||
echo $match | grep -q $i
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "1"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
echo "0"
|
||||
|
||||
exit 0
|
||||
@@ -1,81 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
# mozconfig2defs.sh - Translates mozconfig.sh into options for client.mk.
|
||||
# Prints defines to stdout.
|
||||
#
|
||||
# See load-mozconfig.sh for more details
|
||||
#
|
||||
# Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
|
||||
|
||||
print_header() {
|
||||
echo "# gmake"
|
||||
echo "# This file is automatically generated for client.mk."
|
||||
echo "# Do not edit. Edit $MOZCONFIG instead."
|
||||
echo
|
||||
}
|
||||
|
||||
ac_add_options() {
|
||||
for _opt
|
||||
do
|
||||
# Escape shell characters, space, tab, dollar, quote, backslash,
|
||||
# and substitute '@<word>@' with '$(<word)'.
|
||||
_opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g; s/@\([^@]*\)@/\$(\1)/g;'`
|
||||
case "$_opt" in
|
||||
--with-nspr=* ) echo MOZ_WITH_NSPR=`expr $_opt : ".*=\(.*\)"` ;;
|
||||
--with-pthreads* ) echo MOZ_WITH_PTHREADS=1 ;;
|
||||
--*-* ) echo "# $_opt is not used by client.mk" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
mk_add_options() {
|
||||
for _opt
|
||||
do
|
||||
# Escape shell characters, space, tab, dollar, quote, backslash,
|
||||
# and substitute '@<word>@' with '$(<word)'.
|
||||
echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g; s/@\([^@]*\)@/\$(\1)/g;'
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
out_file=$1
|
||||
tmp_file="$out_file-tmp$$"
|
||||
|
||||
trap "rm -f $tmp_file; exit 1" 1 2 15
|
||||
|
||||
# find-mozconfig.sh
|
||||
# In params: $MOZCONFIG $HOME ($MOZ_MYCONFIG)
|
||||
MOZCONFIG=`\`dirname $0\`/find-mozconfig.sh`
|
||||
|
||||
if [ "$MOZCONFIG" ]
|
||||
then
|
||||
print_header >$tmp_file
|
||||
. $MOZCONFIG >> $tmp_file
|
||||
|
||||
if cmp -s $tmp_file $out_file; then
|
||||
rm $tmp_file
|
||||
else
|
||||
mv -f $tmp_file $out_file
|
||||
fi
|
||||
else
|
||||
echo "# This file is automatically generated for client.mk." > $out_file
|
||||
fi
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
# mozconfig2defs.sh - Translates mozconfig.sh into options for client.mk.
|
||||
# Prints defines to stdout.
|
||||
#
|
||||
# See load-mozconfig.sh for more details
|
||||
#
|
||||
# Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
|
||||
|
||||
ac_add_options() {
|
||||
for _opt
|
||||
do
|
||||
# Escape shell characters, space, tab, dollar, quote, backslash,
|
||||
# and substitute '@<word>@' with '$(<word)'.
|
||||
_opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;'`
|
||||
case "$_opt" in
|
||||
--*-*= ) query_string="$query_string$_opt&" ;;
|
||||
--*-* ) query_string="$query_string$_opt=yes&" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
mk_add_options() {
|
||||
for _opt
|
||||
do
|
||||
# Escape shell characters, space, tab, dollar, quote, backslash,
|
||||
# and substitute '@<word>@' with '$(<word)'.
|
||||
query_string=$query_string`echo "$_opt&" | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;'`
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
|
||||
# find-mozconfig.sh
|
||||
# In params: $MOZCONFIG $HOME ($MOZ_MYCONFIG)
|
||||
MOZCONFIG=`\`dirname $0\`/find-mozconfig.sh`
|
||||
|
||||
if [ "$MOZCONFIG" ]
|
||||
then
|
||||
query_string="?"
|
||||
. $MOZCONFIG
|
||||
echo `expr "$query_string" : "\(.*\)."`
|
||||
|
||||
fi
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# This script will print the depth path for a mozilla directory based
|
||||
# on the info in Makefile.in
|
||||
#
|
||||
# Its a hack. Its brute force. Its horrible.
|
||||
# It dont use Artificial Intelligence. It dont use Virtual Reality.
|
||||
# Its not perl. Its not python. But it works.
|
||||
#
|
||||
# Usage: print-depth-path.sh
|
||||
#
|
||||
# Send comments, improvements, bugs to ramiro@netscape.com
|
||||
#
|
||||
|
||||
# Make sure a Makefile.in exists
|
||||
if [ ! -f Makefile.in ]
|
||||
then
|
||||
echo
|
||||
echo "There ain't no 'Makefile.in' over here: $pwd, dude."
|
||||
echo
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
# Use DEPTH in the Makefile.in to determine the depth
|
||||
depth=`grep -w DEPTH Makefile.in | grep -e "\.\." | awk -F"=" '{ print $2; }'`
|
||||
|
||||
# Determine the depth count
|
||||
n=`echo $depth | tr '/' ' ' | wc -w`
|
||||
|
||||
# Determine the path (strip anything before the mozilla/ root)
|
||||
path=`pwd | awk -v count=$n -F"/" '\
|
||||
{ for(i=NF-count+0; i <= NF ; i++) \
|
||||
{ \
|
||||
if (i!=NF) \
|
||||
{ printf "%s/", $i } \
|
||||
else \
|
||||
{ printf "%s", $i } \
|
||||
} \
|
||||
}'`
|
||||
|
||||
echo $path
|
||||
@@ -88,9 +88,6 @@ sub BuildMozilla()
|
||||
BuildProject(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "NSStdLib$D.shlb");
|
||||
MakeAlias(":mozilla:lib:mac:NSStdLib:NSStdLib$D.shlb", "$dist_dir");
|
||||
|
||||
BuildProject(":mozilla:modules:libreg:macbuild:libreg.mcp", "libreg$D.shlb");
|
||||
MakeAlias(":mozilla:modules:libreg:macbuild:libreg$D.shlb", "$dist_dir");
|
||||
|
||||
BuildProject(":mozilla:xpcom:macbuild:xpcomPPC.mcp", "xpcom$D.shlb");
|
||||
MakeAlias(":mozilla:xpcom:macbuild:xpcom$D.shlb", "$dist_dir");
|
||||
|
||||
|
||||
@@ -65,20 +65,12 @@
|
||||
#pragma peephole off
|
||||
#pragma optimize_for_size off
|
||||
#else
|
||||
#pragma traceback on /* leave on until the final release, so MacsBug logs are interpretable */
|
||||
#pragma traceback off
|
||||
#pragma global_optimizer on
|
||||
#pragma optimization_level 4
|
||||
#pragma scheduling 603
|
||||
#pragma scheduling 604
|
||||
#pragma peephole on
|
||||
#pragma optimize_for_size on
|
||||
|
||||
#pragma opt_strength_reduction on
|
||||
#pragma opt_propagation on
|
||||
#pragma opt_loop_invariants on
|
||||
#pragma opt_lifetimes on
|
||||
#pragma opt_dead_code on
|
||||
#pragma opt_dead_assignments on
|
||||
#pragma opt_common_subs on
|
||||
#endif
|
||||
|
||||
#else /* ...generating 68k */
|
||||
|
||||
@@ -176,28 +176,14 @@ sub BuildDist()
|
||||
InstallFromManifest(":mozilla:nsprpub:lib:msgc:include:MANIFEST", "$distdirectory:nspr:");
|
||||
|
||||
#INTL
|
||||
#UCONV
|
||||
InstallFromManifest(":mozilla:intl:uconv:public:MANIFEST", "$distdirectory:uconv:");
|
||||
InstallFromManifest(":mozilla:intl:uconv:ucvlatin:MANIFEST", "$distdirectory:uconv:");
|
||||
InstallFromManifest(":mozilla:intl:uconv:ucvja:MANIFEST", "$distdirectory:uconv:");
|
||||
InstallFromManifest(":mozilla:intl:uconv:ucvja2:MANIFEST", "$distdirectory:uconv:");
|
||||
# InstallFromManifest(":mozilla:intl:uconv:ucvtw:MANIFEST", "$distdirectory:uconv:");
|
||||
# InstallFromManifest(":mozilla:intl:uconv:ucvtw2:MANIFEST", "$distdirectory:uconv:");
|
||||
# InstallFromManifest(":mozilla:intl:uconv:ucvcn:MANIFEST", "$distdirectory:uconv:");
|
||||
# InstallFromManifest(":mozilla:intl:uconv:ucvko:MANIFEST", "$distdirectory:uconv:");
|
||||
# InstallFromManifest(":mozilla:intl:uconv:ucvth:MANIFEST", "$distdirectory:uconv:");
|
||||
# InstallFromManifest(":mozilla:intl:uconv:ucvvt:MANIFEST", "$distdirectory:uconv:");
|
||||
|
||||
|
||||
#UNICHARUTIL
|
||||
InstallFromManifest(":mozilla:intl:unicharutil:public:MANIFEST", "$distdirectory:unicharutil");
|
||||
|
||||
#LOCALE
|
||||
InstallFromManifest(":mozilla:intl:locale:public:MANIFEST", "$distdirectory:locale:");
|
||||
|
||||
#LWBRK
|
||||
InstallFromManifest(":mozilla:intl:lwbrk:public:MANIFEST", "$distdirectory:lwbrk:");
|
||||
|
||||
#STRRES
|
||||
InstallFromManifest(":mozilla:intl:strres:public:MANIFEST", "$distdirectory:strres:");
|
||||
|
||||
@@ -209,8 +195,7 @@ sub BuildDist()
|
||||
|
||||
#XPCOM
|
||||
InstallFromManifest(":mozilla:xpcom:public:MANIFEST", "$distdirectory:xpcom:");
|
||||
InstallFromManifest(":mozilla:xpcom:src:MANIFEST", "$distdirectory:xpcom:");
|
||||
|
||||
|
||||
#ZLIB
|
||||
InstallFromManifest(":mozilla:modules:zlib:src:MANIFEST", "$distdirectory:zlib:");
|
||||
|
||||
@@ -253,9 +238,6 @@ sub BuildDist()
|
||||
InstallFromManifest(":mozilla:modules:oji:src:MANIFEST", "$distdirectory:oji:");
|
||||
InstallFromManifest(":mozilla:modules:oji:public:MANIFEST", "$distdirectory:oji:");
|
||||
|
||||
#DBM
|
||||
InstallFromManifest(":mozilla:dbm:include:MANIFEST", "$distdirectory:dbm:");
|
||||
|
||||
#LAYERS (IS THIS STILL NEEDED)
|
||||
InstallFromManifest(":mozilla:lib:liblayer:include:MANIFEST", "$distdirectory:layers:");
|
||||
|
||||
@@ -291,17 +273,17 @@ sub BuildDist()
|
||||
|
||||
#WEBSHELL
|
||||
InstallFromManifest(":mozilla:webshell:public:MANIFEST", "$distdirectory:webshell:");
|
||||
InstallFromManifest(":mozilla:webshell:tests:viewer:public:MANIFEST", "$distdirectory:webshell:");
|
||||
InstallFromManifest(":mozilla:webshell:tests:viewer:public:MANIFEST", "$distdirectory:webshell:");
|
||||
|
||||
#LAYOUT
|
||||
InstallFromManifest(":mozilla:layout:build:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:base:public:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:document:src:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:document:src:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:style:public:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:style:src:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:base:src:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:forms:public:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:table:public:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:html:table:public:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:base:src:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:events:public:MANIFEST", "$distdirectory:layout:");
|
||||
InstallFromManifest(":mozilla:layout:events:src:MANIFEST", "$distdirectory:layout:");
|
||||
@@ -332,13 +314,9 @@ sub BuildDist()
|
||||
|
||||
#HTMLPARSER
|
||||
InstallFromManifest(":mozilla:htmlparser:src:MANIFEST", "$distdirectory:htmlparser:");
|
||||
|
||||
#EXPAT
|
||||
InstallFromManifest(":mozilla:expat:xmlparse:MANIFEST", "$distdirectory:expat:");
|
||||
|
||||
|
||||
#RDF
|
||||
InstallFromManifest(":mozilla:rdf:base:public:MANIFEST", "$distdirectory:rdf:");
|
||||
InstallFromManifest(":mozilla:rdf:util:public:MANIFEST", "$distdirectory:rdf:");
|
||||
InstallFromManifest(":mozilla:rdf:content:public:MANIFEST", "$distdirectory:rdf:");
|
||||
InstallFromManifest(":mozilla:rdf:datasource:public:MANIFEST", "$distdirectory:rdf:");
|
||||
InstallFromManifest(":mozilla:rdf:build:MANIFEST", "$distdirectory:rdf:");
|
||||
@@ -353,22 +331,22 @@ sub BuildDist()
|
||||
#FULL CIRCLE
|
||||
if ($main::MOZ_FULLCIRCLE)
|
||||
{
|
||||
InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory");
|
||||
InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory");
|
||||
|
||||
if ($main::DEBUG)
|
||||
{
|
||||
#InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory:viewer_debug:");
|
||||
#InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory:viewer_debug:");
|
||||
}
|
||||
else
|
||||
{
|
||||
#InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory:viewer:");
|
||||
InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory");
|
||||
#InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory:viewer:");
|
||||
InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory");
|
||||
}
|
||||
}
|
||||
|
||||
# XPAPPS
|
||||
InstallFromManifest(":mozilla:xpfe:AppCores:public:MANIFEST", "$distdirectory:xpfe:");
|
||||
InstallFromManifest(":mozilla:xpfe:appshell:public:MANIFEST", "$distdirectory:xpfe:");
|
||||
InstallFromManifest(":mozilla:xpfe:AppCores:public:MANIFEST", "$distdirectory:xpfe:");
|
||||
InstallFromManifest(":mozilla:xpfe:appshell:public:MANIFEST", "$distdirectory:xpfe:");
|
||||
|
||||
#// To get out defines in all the project, dummy alias NGLayoutConfigInclude.h into MacConfigInclude.h
|
||||
MakeAlias(":mozilla:config:mac:NGLayoutConfigInclude.h", ":mozilla:dist:config:MacConfigInclude.h");
|
||||
@@ -388,8 +366,10 @@ sub BuildStubs()
|
||||
#//
|
||||
#// Clean projects
|
||||
#//
|
||||
BuildProjectClean(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "Stubs");
|
||||
BuildProjectClean(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "Stubs");
|
||||
BuildProjectClean(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp", "Stubs");
|
||||
# BuildProjectClean(":mozilla:cmd:macfe:projects:client:Client.mcp", "Stubs");
|
||||
}
|
||||
|
||||
|
||||
@@ -401,14 +381,13 @@ sub BuildStubs()
|
||||
#// are the same.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildOneProject($$$$$$)
|
||||
sub BuildOneProject($$$$$)
|
||||
{
|
||||
my ($project_path, $target_name, $toc_file, $alias_shlb, $alias_xSYM, $component) = @_;
|
||||
my ($project_path, $target_name, $toc_file, $alias_shlb, $alias_xSYM) = @_;
|
||||
|
||||
# $D becomes a suffix to target names for selecting either the debug or non-debug target of a project
|
||||
my($D) = $main::DEBUG ? "Debug" : "";
|
||||
my($dist_dir) = _getDistDirectory();
|
||||
my($component_dir) = $component ? "Components:" : "";
|
||||
|
||||
my($project_dir) = $project_path;
|
||||
$project_dir =~ s/:[^:]+$/:/; # chop off leaf name
|
||||
@@ -426,7 +405,7 @@ sub BuildOneProject($$$$$$)
|
||||
|
||||
BuildProject($project_path, $target_name);
|
||||
|
||||
$alias_shlb ? MakeAlias("$project_dir$target_name", "$dist_dir$component_dir") : 0;
|
||||
$alias_shlb ? MakeAlias("$project_dir$target_name", "$dist_dir") : 0;
|
||||
$alias_xSYM ? MakeAlias("$project_dir$target_name.xSYM", "$dist_dir") : 0;
|
||||
}
|
||||
|
||||
@@ -461,77 +440,63 @@ sub BuildCommonProjects()
|
||||
BuildProject(":mozilla:cmd:macfe:projects:interfaceLib:Interface.mcp", "MacOS Interfaces");
|
||||
}
|
||||
|
||||
BuildOneProject(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp", "NSRuntime$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp", "NSRuntime$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildProject(":mozilla:lib:mac:MoreFiles:build:MoreFilesPPC.mcp", "MoreFiles.o");
|
||||
BuildOneProject(":mozilla:lib:mac:MoreFiles:build:MoreFilesPPC.mcp", "MoreFiles$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildProject(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "MemAllocator$D.o");
|
||||
BuildOneProject(":mozilla:nsprpub:macbuild:NSPR20PPC.mcp", "NSPR20$D.shlb", "NSPR20.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "NSStdLib$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "MemAllocator$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:nsprpub:macbuild:NSPR20PPC.mcp", "NSPR20$D.shlb", "NSPR20.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "NSStdLib$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:jpeg:macbuild:JPEG.mcp", "JPEG$D.shlb", "JPEG.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:xpcom:macbuild:xpcomPPC.mcp", "xpcom$D.shlb", "xpcom.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:js:macbuild:JavaScript.mcp", "JavaScript$D.shlb", "JavaScript.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:js:macbuild:LiveConnect.mcp", "LiveConnect$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:modules:zlib:macbuild:zlib.mcp", "zlib$D.shlb", "zlib.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:jpeg:macbuild:JPEG.mcp", "JPEG$D.shlb", "JPEG.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:modules:libreg:macbuild:libreg.mcp", "libreg$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:xpcom:macbuild:xpcomPPC.mcp", "xpcom$D.shlb", "xpcom.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:js:macbuild:JavaScript.mcp", "JavaScript$D.shlb", "JavaScript.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:caps:macbuild:Caps.mcp", "Caps$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:js:macbuild:LiveConnect.mcp", "LiveConnect$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:modules:oji:macbuild:oji.mcp", "oji$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:modules:zlib:macbuild:zlib.mcp", "zlib$D.shlb", "zlib.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:modules:libpref:macbuild:libpref.mcp", "libpref$D.shlb", "libpref.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:base:macbuild:base.mcp", "base$D.shlb", "base.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:intl:uconv:macbuild:uconv.mcp", "uconv$D.shlb", "uconv.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvlatin.mcp", "ucvlatin$D.shlb", "uconvlatin.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvja.mcp", "ucvja$D.shlb", "ucvja.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:intl:unicharutil:macbuild:unicharutil.mcp", "unicharutil$D.shlb", "unicharutil.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:intl:locale:macbuild:locale.mcp", "nslocale$D.shlb", "nslocale.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:caps:macbuild:Caps.mcp", "Caps$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:modules:oji:macbuild:oji.mcp", "oji$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:modules:libpref:macbuild:libpref.mcp", "libpref$D.shlb", "libpref.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:intl:strres:macbuild:strres.mcp", "strres$D.shlb", "strres.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:base:macbuild:base.mcp", "base$D.shlb", "base.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
# International projects
|
||||
BuildOneProject(":mozilla:intl:uconv:macbuild:uconv.mcp", "uconv$D.shlb", "uconv.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvlatin.mcp", "ucvlatin$D.shlb", "uconvlatin.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
#// removing powerplant - long live powerplant
|
||||
# BuildOneProject(":mozilla:lib:mac:PowerPlant:PowerPlant.mcp", "PowerPlant$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvja.mcp", "ucvja$D.shlb", "ucvja.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvja2.mcp", "ucvja2$D.shlb", "ucvja2.toc", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
|
||||
#// Have not enable yet... place holder
|
||||
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvtw.mcp", "ucvtw$D.shlb", "ucvtw.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvtw2.mcp", "ucvtw2$D.shlb", "ucvtw2.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvcn.mcp", "ucvcn$D.shlb", "ucvcn.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvko.mcp", "ucvko$D.shlb", "ucvko.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvvt.mcp", "ucvvt$D.shlb", "ucvvt.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvth.mcp", "ucvth$D.shlb", "ucvth.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:intl:unicharutil:macbuild:unicharutil.mcp", "unicharutil$D.shlb", "unicharutil.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:intl:locale:macbuild:locale.mcp", "nslocale$D.shlb", "nslocale.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:intl:lwbrk:macbuild:lwbrk.mcp", "lwbrk$D.shlb", "lwbrk.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:intl:strres:macbuild:strres.mcp", "strres$D.shlb", "strres.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
|
||||
BuildOneProject(":mozilla:modules:libutil:macbuild:libutil.mcp", "libutil$D.shlb", "libutil.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:modules:libutil:macbuild:libutil.mcp", "libutil$D.shlb", "libutil.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
ReconcileProject(":mozilla:modules:libimg:macbuild:png.mcp", ":mozilla:modules:libimg:macbuild:png.toc");
|
||||
BuildProject(":mozilla:modules:libimg:macbuild:png.mcp", "png$D.o");
|
||||
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:libimg.mcp", "libimg$D.shlb", "libimg.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:libimg.mcp", "libimg$D.shlb", "libimg.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:network:macbuild:network.mcp", "NetworkModular$D.shlb", "network.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:network:macbuild:network.mcp", "NetworkModular$D.shlb", "network.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
#// XXX moved this TEMPORARILY to layout while we sort out a dependency
|
||||
# BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "rdf$D.shlb", "rdf.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
# BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "rdf$D.shlb", "rdf.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
}
|
||||
|
||||
|
||||
@@ -578,7 +543,7 @@ sub MakeResouceAliases()
|
||||
#//
|
||||
my($resource_dir) = "$dist_dir" . "res:";
|
||||
MakeAlias(":mozilla:layout:html:document:src:ua.css", "$resource_dir");
|
||||
MakeAlias(":mozilla:webshell:tests:viewer:resources:viewer.properties", "$resource_dir");
|
||||
MakeAlias(":mozilla:webshell:tests:viewer:resources:viewer.properties", "$resource_dir");
|
||||
|
||||
my($html_dir) = "$resource_dir" . "html:";
|
||||
MakeAlias(":mozilla:layout:html:base:src:broken-image.gif", "$html_dir");
|
||||
@@ -604,7 +569,6 @@ sub MakeResouceAliases()
|
||||
BuildFolderResourceAliases(":mozilla:xpfe:browser:src:", "$samples_dir");
|
||||
BuildFolderResourceAliases(":mozilla:xpfe:AppCores:xul:", "$samples_dir");
|
||||
BuildFolderResourceAliases(":mozilla:xpfe:AppCores:xul:resources:", "$toolbar_dir");
|
||||
MakeAlias(":mozilla:xpfe:AppCores:xul:resources:throbbingN.gif", "$throbber_dir");
|
||||
}
|
||||
|
||||
|
||||
@@ -645,26 +609,26 @@ sub BuildLayoutProjects()
|
||||
#// Build Layout projects
|
||||
#//
|
||||
|
||||
BuildOneProject(":mozilla:htmlparser:macbuild:htmlparser.mcp", "htmlparser$D.shlb", "htmlparser.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:htmlparser:macbuild:htmlparser.mcp", "htmlparser$D.shlb", "htmlparser.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:dom:macbuild:dom.mcp", "dom$D.shlb", "dom.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:dom:macbuild:dom.mcp", "dom$D.shlb", "dom.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:gfx:macbuild:gfx.mcp", "gfx$D.shlb", "gfx.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:gfx:macbuild:gfx.mcp", "gfx$D.shlb", "gfx.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:modules:plugin:macbuild:plugin.mcp", "plugin$D.shlb", "plugin.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:modules:plugin:macbuild:plugin.mcp", "plugin$D.shlb", "plugin.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:layout:macbuild:layout.mcp", "layout$D.shlb", "layout.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:layout:macbuild:layout.mcp", "layout$D.shlb", "layout.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:view:macbuild:view.mcp", "view$D.shlb", "view.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:view:macbuild:view.mcp", "view$D.shlb", "view.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:widget:macbuild:widget.mcp", "widget$D.shlb", "widget.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:widget:macbuild:widget.mcp", "widget$D.shlb", "widget.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:webshell:macbuild:webshell.mcp", "webshell$D.shlb", "webshell.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:webshell:macbuild:webshell.mcp", "webshell$D.shlb", "webshell.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:webshell:embed:mac:RaptorShell.mcp", "RaptorShell$D.shlb", "RaptorShell.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:webshell:embed:mac:RaptorShell.mcp", "RaptorShell$D.shlb", "RaptorShell.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
#// XXX this is here because of a very TEMPORARY dependency
|
||||
BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "rdf$D.shlb", "rdf.toc", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "rdf$D.shlb", "rdf.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
}
|
||||
|
||||
|
||||
@@ -681,11 +645,11 @@ sub BuildEditorProjects()
|
||||
my($D) = $main::DEBUG ? "Debug" : "";
|
||||
my($dist_dir) = _getDistDirectory();
|
||||
|
||||
BuildOneProject(":mozilla:editor:txmgr:macbuild:txmgr.mcp", "EditorTxmgr$D.shlb", "txmgr.toc", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
BuildOneProject(":mozilla:editor:txmgr:macbuild:txmgr.mcp", "EditorTxmgr$D.shlb", "txmgr.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:editor:guimgr:macbuild:EditorGuiManager.mcp", "EditorGuiManager$D.shlb", "EditorGuiManager.toc", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
BuildOneProject(":mozilla:editor:guimgr:macbuild:EditorGuiManager.mcp", "EditorGuiManager$D.shlb", "EditorGuiManager.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:editor:macbuild:editor.mcp", "EditorCore$D.shlb", "EditorCore.toc", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
BuildOneProject(":mozilla:editor:macbuild:editor.mcp", "EditorCore$D.shlb", "EditorCore.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
}
|
||||
|
||||
@@ -703,9 +667,9 @@ sub BuildViewerProjects()
|
||||
my($D) = $main::DEBUG ? "Debug" : "";
|
||||
my($dist_dir) = _getDistDirectory();
|
||||
|
||||
BuildOneProject(":mozilla:webshell:tests:viewer:mac:viewer.mcp", "viewer$D", "viewer.toc", 0, 0, 0);
|
||||
BuildOneProject(":mozilla:webshell:tests:viewer:mac:viewer.mcp", "viewer$D", "viewer.toc", 0, 0);
|
||||
|
||||
# BuildOneProject(":mozilla:xpfe:macbuild:xpfeviewer.mcp", "xpfeviewer$D.shlb", "xpfeviewer.toc", 0, 0, 0);
|
||||
# BuildOneProject(":mozilla:xpfe:macbuild:xpfeviewer.mcp", "xpfeviewer$D.shlb", "xpfeviewer.toc", 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -722,11 +686,11 @@ sub BuildXPAppProjects()
|
||||
my($D) = $main::DEBUG ? "Debug" : "";
|
||||
my($dist_dir) = _getDistDirectory();
|
||||
|
||||
BuildOneProject(":mozilla:xpfe:appshell:macbuild:AppShell.mcp", "AppShell$D.shlb", "AppShell.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:xpfe:appshell:macbuild:AppShell.mcp", "AppShell$D.shlb", "AppShell.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:xpfe:AppCores:macbuild:AppCores.mcp", "AppCores$D.shlb", "AppCores.toc", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:xpfe:AppCores:macbuild:AppCores.mcp", "AppCores$D.shlb", "AppCores.toc", 1, $main::ALIAS_SYM_FILES);
|
||||
|
||||
BuildOneProject(":mozilla:xpfe:bootstrap:macbuild:apprunner.mcp", "apprunner$D", "apprunner.toc", 0, 0, 1);
|
||||
BuildOneProject(":mozilla:xpfe:bootstrap:macbuild:apprunner.mcp", "apprunner$D", "apprunner.toc", 0, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
#!perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# nglayout build script (debug)
|
||||
#
|
||||
use Mac::Processes;
|
||||
use NGLayoutBuildList;
|
||||
use Cwd;
|
||||
use Moz;
|
||||
|
||||
# configuration variables
|
||||
$DEBUG = 1;
|
||||
$ALIAS_SYM_FILES = $DEBUG;
|
||||
$CLOBBER_LIBS = 1; # turn on to clobber existing libs and .xSYM files before
|
||||
# building each project
|
||||
$MOZ_FULLCIRCLE = 0;
|
||||
|
||||
$pull{all} = 1;
|
||||
$pull{lizard} = 0;
|
||||
$pull{xpcom} = 0;
|
||||
$pull{imglib} = 0;
|
||||
$pull{netlib} = 0;
|
||||
$pull{nglayout} = 0;
|
||||
$pull{mac} = 0;
|
||||
|
||||
$build{all} = 1; # turn off to do individual builds
|
||||
$build{dist} = 0;
|
||||
$build{stubs} = 0;
|
||||
$build{common} = 0;
|
||||
$build{nglayout} = 0;
|
||||
$build{resources} = 0;
|
||||
$build{editor} = 0;
|
||||
$build{viewer} = 0;
|
||||
$build{xpapp} = 0;
|
||||
|
||||
if ($pull{all})
|
||||
{
|
||||
foreach $k (keys(%pull))
|
||||
{
|
||||
$pull{$k} = 1;
|
||||
}
|
||||
}
|
||||
if ($build{all})
|
||||
{
|
||||
foreach $k (keys(%build))
|
||||
{
|
||||
$build{$k} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
# do the work
|
||||
# you should not have to edit anything bellow
|
||||
|
||||
chdir("::::");
|
||||
$MOZ_SRC = cwd();
|
||||
|
||||
if ($MOZ_FULLCIRCLE)
|
||||
{
|
||||
#// Get the Build Number for the Master.ini(Full Circle) n'stuff
|
||||
$buildnum = Moz::SetBuildNumber();
|
||||
}
|
||||
|
||||
OpenErrorLog("NGLayoutDebugBuildLog");
|
||||
#OpenErrorLog("Mozilla.BuildLog"); # Tinderbox requires that name
|
||||
|
||||
Moz::StopForErrors();
|
||||
#Moz::DontStopForErrors();
|
||||
|
||||
if ($pull{all}) {
|
||||
Checkout();
|
||||
}
|
||||
|
||||
chdir($MOZ_SRC);
|
||||
BuildDist();
|
||||
|
||||
chdir($MOZ_SRC);
|
||||
BuildProjects();
|
||||
|
||||
print "Build layout complete\n";
|
||||
@@ -29,7 +29,7 @@ use Moz;
|
||||
|
||||
$DEBUG = 1;
|
||||
$ALIAS_SYM_FILES = 0;
|
||||
$CLOBBER_LIBS = 1;
|
||||
$CLOBBER_LIBS = 0;
|
||||
$MOZ_FULLCIRCLE = 0;
|
||||
|
||||
$pull{all} = 0;
|
||||
|
||||
@@ -29,7 +29,7 @@ use Moz;
|
||||
|
||||
$DEBUG = 0;
|
||||
$ALIAS_SYM_FILES = 0;
|
||||
$CLOBBER_LIBS = 1;
|
||||
$CLOBBER_LIBS = 0;
|
||||
$MOZ_FULLCIRCLE = 0;
|
||||
|
||||
$pull{all} = 1;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
@@ -107,10 +109,10 @@ LINCS= $(LINCS) \
|
||||
|
||||
LLIBS = \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\xplib.lib \
|
||||
$(DIST)\lib\zip3250.lib \
|
||||
$(ZIPLIB) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsCapsEnums.h"
|
||||
#include "nsCCapsManager.h"
|
||||
#include "nsICodebasePrincipal.h"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "nsCCapsManager.h"
|
||||
#include "nsCCapsManagerFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsRepository.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
@@ -137,7 +137,7 @@ nsCCapsManagerFactory::nsCCapsManagerFactory(void)
|
||||
if ( (err == NS_OK) && (m_pNSIFactory != NULL) )
|
||||
{
|
||||
NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID);
|
||||
nsComponentManager::RegisterFactory(kCCapsManagerCID, 0, 0,
|
||||
nsRepository::RegisterFactory(kCCapsManagerCID, 0, 0,
|
||||
m_pNSIFactory, PR_FALSE);
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ nsCCapsManagerFactory::~nsCCapsManagerFactory()
|
||||
if(mRefCnt == 0)
|
||||
{
|
||||
NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID);
|
||||
nsComponentManager::UnregisterFactory(kCCapsManagerCID, (nsIFactory *)m_pNSIFactory);
|
||||
nsRepository::UnregisterFactory(kCCapsManagerCID, (nsIFactory *)m_pNSIFactory);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,30 +14,21 @@
|
||||
# Reserved.
|
||||
|
||||
DEPTH=.
|
||||
IGNORE_MANIFEST=1
|
||||
THIS_MAKEFILE=nglayout.mak
|
||||
THAT_MAKEFILE=makefile.win
|
||||
|
||||
!if !defined(MOZ_TOP)
|
||||
#enable builds from changed top level directories
|
||||
MOZ_TOP=mozilla
|
||||
!endif
|
||||
|
||||
#
|
||||
# Arbitrary required defines (should probably just turn them on in the
|
||||
# tree by default)
|
||||
|
||||
MODULAR_NETLIB = 1
|
||||
STANDALONE_IMAGE_LIB = 1
|
||||
NGLAYOUT_PLUGINS = 1
|
||||
|
||||
#
|
||||
# Command macro defines
|
||||
#
|
||||
|
||||
# let's be explicit about CVSROOT... some windows cvs clients
|
||||
# are too stupid to correctly work without the -d option
|
||||
!if defined(MOZ_DATE)
|
||||
CVSCO = cvs -q co -P -D "$(MOZ_DATE)"
|
||||
!elseif defined(CVSROOT)
|
||||
CVSCO = cvs -d $(CVSROOT) -q co -P
|
||||
!else
|
||||
CVSCO = cvs -q co -P
|
||||
!endif
|
||||
@@ -66,37 +57,101 @@ CVSCO_RAPTOR = $(CVSCO)
|
||||
CVSCO_LIZARD = $(CVSCO)
|
||||
CVSCO_NETWORK = $(CVSCO)
|
||||
|
||||
## The master target
|
||||
|
||||
############################################################
|
||||
|
||||
pull_and_build_all: pull_all build_all
|
||||
|
||||
## This should really be in a different file, like client.mak
|
||||
## but it's OK here for now.
|
||||
|
||||
## Rules for pulling the source from the cvs repository
|
||||
############################################################
|
||||
|
||||
pull_and_build_all: pull_all build_all
|
||||
pull_and_build_all: pull_seamonkey build_seamonkey
|
||||
|
||||
pull_all: pull_seamonkey
|
||||
|
||||
pull_nglayout: pull_lizard pull_xpcom pull_imglib pull_netlib pull_nglayout \
|
||||
pull_editor
|
||||
|
||||
pull_seamonkey:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) SeaMonkeyAll
|
||||
$(CVSCO) $(MOZ_TOP)/nsprpub
|
||||
$(CVSCO_LIZARD) SeaMonkeyEditor
|
||||
|
||||
pull_lizard:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/LICENSE
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/LEGAL
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/config
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/dbm
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/lib/liblayer
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/modules/zlib
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/modules/libutil
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/nsprpub
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/sun-java
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/nav-java
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/js
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/modules/security/freenav
|
||||
$(CVSCO_LIBPREF) $(MOZ_TOP)/modules/libpref
|
||||
$(CVSCO_PLUGIN) $(MOZ_TOP)/modules/plugin
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/modules/oji
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/caps
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/rdf
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/intl
|
||||
!if defined(NGPREFS)
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/cmd/wincom
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/cmd/winfe/defaults.h
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/cmd/winfe/nsIDefaultBrowser.h
|
||||
$(CVSCO_LIZARD) $(MOZ_TOP)/cmd/winfe/prefs
|
||||
!endif
|
||||
|
||||
pull_xpcom:
|
||||
@cd $(MOZ_SRC)\.
|
||||
$(CVSCO_XPCOM) $(MOZ_TOP)/modules/libreg
|
||||
$(CVSCO_XPCOM) $(MOZ_TOP)/xpcom
|
||||
|
||||
pull_imglib:
|
||||
@cd $(MOZ_SRC)\.
|
||||
$(CVSCO_IMGLIB) $(MOZ_TOP)/jpeg
|
||||
$(CVSCO_IMGLIB) $(MOZ_TOP)/modules/libutil
|
||||
$(CVSCO_IMGLIB) $(MOZ_TOP)/modules/libimg
|
||||
|
||||
pull_netlib:
|
||||
@cd $(MOZ_SRC)\.
|
||||
$(CVSCO_NETWORK) $(MOZ_TOP)/lib/xp
|
||||
$(CVSCO_NETWORK) $(MOZ_TOP)/lib/libpwcac
|
||||
$(CVSCO_NETWORK) $(MOZ_TOP)/network
|
||||
$(CVSCO_NETWORK) $(MOZ_TOP)/include
|
||||
|
||||
pull_nglayout:
|
||||
@cd $(MOZ_SRC)\.
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/base
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/dom
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/gfx
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/htmlparser
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/layout
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/view
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/webshell
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/widget
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/xpfe
|
||||
|
||||
pull_editor:
|
||||
@cd $(MOZ_SRC)\.
|
||||
$(CVSCO_RAPTOR) $(MOZ_TOP)/editor
|
||||
|
||||
############################################################
|
||||
|
||||
# nmake has to be hardcoded, or we have to depend on mozilla/config
|
||||
# being pulled already to figure out what $(NMAKE) should be.
|
||||
clobber_all:: clobber_nglayout
|
||||
|
||||
clobber_all:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
rd /s /q dist
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
depend:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win depend
|
||||
|
||||
build_all:
|
||||
clobber_nglayout:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win all
|
||||
nmake -f nglayout.mak clobber_all $(NGLAYOUT_ENV_VARS)
|
||||
|
||||
build_all: build_seamonkey build_apprunner
|
||||
|
||||
build_seamonkey:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f nglayout.mak all
|
||||
|
||||
build_apprunner:
|
||||
@cd $(MOZ_SRC)\mozilla\xpfe\.
|
||||
nmake -f makefile.win
|
||||
|
||||
@@ -14,305 +14,180 @@
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
# Build the Mozilla client.
|
||||
#
|
||||
# This needs CVSROOT set to work, e.g.,
|
||||
# setenv CVSROOT :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
# or
|
||||
# setenv CVSROOT :pserver:username%somedomain.org@cvs.mozilla.org:/cvsroot
|
||||
# This needs CVSROOT set to work, e.g.
|
||||
# setenv CVSROOT :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
# --or--
|
||||
# setenv CVSROOT :pserver:username%somedomain.org@cvs.mozilla.org:/cvsroot
|
||||
#
|
||||
# To checkout and build a new tree,
|
||||
# 1. cvs co mozilla/client.mk
|
||||
# 2. cd mozilla
|
||||
# 3. gmake -f client.mk webconfig
|
||||
# (or goto http://cvs-mirror.mozilla.org/webtools/build/config.cgi)
|
||||
# 4. gmake -f client.mk
|
||||
# Usage:
|
||||
# Pull the source:
|
||||
# cvs checkout mozilla/client.mk
|
||||
# gmake -f mozilla/client.mk checkout
|
||||
#
|
||||
# To checkout (update) and build an existing tree,
|
||||
# gmake -f client.mk
|
||||
# Build NSPR, maybe only once:
|
||||
# gmake -f mozilla/client.mk nspr
|
||||
#
|
||||
# Other targets (gmake -f client.mk [targets...]),
|
||||
# checkout (also pull_all)
|
||||
# build (also build_all)
|
||||
# realclean (also clobber_all)
|
||||
# clean (also clobber)
|
||||
# Build the client:
|
||||
# gmake -f mozilla/client.mk build
|
||||
#
|
||||
# The nspr library is handled as follows,
|
||||
# Read $HOME/.mozconfig.sh (or $(TOPSRCDIR)/mozconfig.sh) and
|
||||
# get the directory specified by --with-nspr.
|
||||
# If the flag is not there, look for nspr in /usr/bin.
|
||||
# Otherwise, build from tip and install in $(OBJDIR)/dist/nspr
|
||||
#
|
||||
# See http://www.mozilla.org/build/unix.html for more information.
|
||||
#
|
||||
# Options:
|
||||
# MOZ_WITH_NSPR - Nspr directory for configure --with-nspr=
|
||||
# MOZ_WITH_PTHREADS - Pthreads for nspr and configure
|
||||
# MOZ_OBJDIR - Destination object directory
|
||||
# also,
|
||||
# MOZ_CO_BRANCH - Branch tag to use for checkout (default: HEAD)
|
||||
# MOZ_CO_MODULE - Module to checkout (default: SeaMonkeyEditor)
|
||||
# MOZ_CVS_FLAGS - Flags to pass cvs (default: -q -z3)
|
||||
# MOZ_CO_FLAGS - Flags to pass after 'cvs co' (default: -P)
|
||||
# see http://www.mozilla.org/unix/ for more information
|
||||
|
||||
CWD := $(shell pwd)
|
||||
ifeq (mozilla, $(notdir $(CWD)))
|
||||
ROOTDIR := $(shell dirname $(CWD))
|
||||
TOPSRCDIR := $(CWD)
|
||||
else
|
||||
ROOTDIR := $(CWD)
|
||||
TOPSRCDIR := $(CWD)/mozilla
|
||||
endif
|
||||
# options:
|
||||
# MOZ_OBJDIR - destination Object Directory
|
||||
# MOZ_CVS_FLAGS - flags to pass to CVS
|
||||
# MOZ_CHECKOUT_FLAGS - flags to pass after cvs co
|
||||
# MOZ_BRANCH - default branch to checkout
|
||||
# MOZ_TOOLKIT - toolkit for configure --enable-toolkit=
|
||||
# NSPR_INSTALL_DIR - nspr directory for configure --with-nspr=
|
||||
|
||||
#
|
||||
# basic static variables
|
||||
#
|
||||
DEPTH = mozilla
|
||||
AUTOCONF = autoconf -l build/autoconf
|
||||
TARGETS = export libs install
|
||||
MKDIR = mkdir
|
||||
SH = /bin/sh
|
||||
CWD = $(shell pwd)
|
||||
SRCDIR = $(CWD)/$(DEPTH)
|
||||
|
||||
AUTOCONF := autoconf
|
||||
MKDIR := mkdir
|
||||
SH := /bin/sh
|
||||
ifndef MAKE
|
||||
MAKE := gmake
|
||||
MAKE = gmake
|
||||
endif
|
||||
|
||||
WEBCONFIG_URL := http://cvs-mirror.mozilla.org/webtools/build/config.cgi
|
||||
WEBCONFIG_FILE := $(HOME)/.mozconfig.sh
|
||||
|
||||
CONFIG_GUESS := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
|
||||
ifdef CONFIG_GUESS
|
||||
CONFIG_GUESS := $(shell $(CONFIG_GUESS))
|
||||
# default objdir, e.g. obj-sparc-sun-solaris2.5.1
|
||||
ifndef MOZ_OBJDIR
|
||||
OBJDIR = $(CWD)/obj-$(shell $(SRCDIR)/build/autoconf/config.guess)
|
||||
else
|
||||
IS_FIRST_CHECKOUT := 1
|
||||
endif
|
||||
|
||||
# Load options from mozconfig.sh
|
||||
# (See build pages, http://www.mozilla.org/build/unix.html,
|
||||
# for how to set up mozconfig.sh.)
|
||||
MOZCONFIG2DEFS := build/autoconf/mozconfig2defs.sh
|
||||
FIND_MOZCONFIG := build/autoconf/find-mozconfig.sh
|
||||
run_for_side_effects := \
|
||||
$(shell cd $(TOPSRCDIR); \
|
||||
if test ! -f $(MOZCONFIG2DEFS); then \
|
||||
(cd ..; cvs co mozilla/$(MOZCONFIG2DEFS) mozilla/$(FIND_MOZCONFIG); ) \
|
||||
else true; \
|
||||
fi; \
|
||||
$(MOZCONFIG2DEFS) .client-defs.mk)
|
||||
include $(TOPSRCDIR)/.client-defs.mk
|
||||
|
||||
ifdef MOZ_OBJDIR
|
||||
OBJDIR := $(MOZ_OBJDIR)
|
||||
else
|
||||
# Default objdir, e.g. mozilla/obj-i686-pc-linux-gnu
|
||||
OBJDIR :=
|
||||
ifdef CONFIG_GUESS
|
||||
OBJDIR := $(ROOTDIR)/obj-$(CONFIG_GUESS)
|
||||
endif
|
||||
OBJDIR = $(MOZ_OBJDIR)
|
||||
endif
|
||||
|
||||
#
|
||||
# Step 1: CVS
|
||||
#
|
||||
# add new cvs-related flags here in the form
|
||||
# ifdef MOZ_FLAGNAME
|
||||
# CVS_FLAGNAME = -option $(CVS_FLAGNAME)
|
||||
# else (optional)
|
||||
# CVS_FLAGNAME = -some -defaults
|
||||
# endif
|
||||
# then:
|
||||
# - DOCUMENT THE NEW OPTION ABOVE!
|
||||
# - add $(CVS_FLAGNAME) to CVS_FLAGS at the bottom
|
||||
|
||||
# Basic CVS flags
|
||||
|
||||
# basic CVS flags
|
||||
ifdef MOZ_CVS_FLAGS
|
||||
CVS_CFLAGS := $(MOZ_CVS_FLAGS)
|
||||
CVS_CFLAGS = $(MOZ_CVS_FLAGS)
|
||||
else
|
||||
CVS_CFLAGS := -q -z 3
|
||||
CVS_CFLAGS = -q -z 3
|
||||
endif
|
||||
|
||||
# Anything that we should use on all checkouts
|
||||
ifdef MOZ_CO_FLAGS
|
||||
CVS_COFLAGS := $(MOZ_CO_FLAGS)
|
||||
# anything that we should use on all checkouts
|
||||
ifdef MOZ_CHECKOUT_FLAGS
|
||||
CVS_COFLAGS = $(MOZ_CHECKOUT_FLAGS)
|
||||
else
|
||||
CVS_COFLAGS := -P
|
||||
CVS_COFLAGS = -P
|
||||
endif
|
||||
|
||||
# The default branch tag
|
||||
ifdef MOZ_CO_BRANCH
|
||||
CVS_BRANCH_FLAGS := -r $(MOZ_CO_BRANCH)
|
||||
# the default branch tag
|
||||
ifdef MOZ_BRANCH
|
||||
CVS_BRANCH_FLAGS = -r $(MOZ_BRANCH_FLAGS)
|
||||
endif
|
||||
|
||||
ifndef MOZ_CO_MODULE
|
||||
MOZ_CO_MODULE := SeaMonkeyEditor
|
||||
endif
|
||||
|
||||
CVS := cvs $(CVS_CFLAGS)
|
||||
CVSCO := $(CVS) co $(CVS_COFLAGS) $(CVS_BRANCH_FLAGS)
|
||||
CVSCO_LOGFILE := $(ROOTDIR)/cvsco.log
|
||||
CVS = cvs $(CVS_CFLAGS)
|
||||
CVSCO = $(CVS) co $(CVS_COFLAGS) $(CVS_BRANCH_FLAGS)
|
||||
|
||||
#
|
||||
# Step 2: NSPR
|
||||
#
|
||||
|
||||
ifeq ($(MOZ_WITH_PTHREADS), 1)
|
||||
NSPR_PTHREAD_FLAG := USE_PTHREADS=1
|
||||
endif
|
||||
|
||||
NSPR_BRANCH :=
|
||||
#NSPR_BRANCH := -rNSPRPUB_RELEASE_3_0
|
||||
|
||||
# These options can be overriden by the user
|
||||
|
||||
ifdef MOZ_WITH_NSPR
|
||||
NSPR_INSTALL_DIR := $(MOZ_WITH_NSPR)
|
||||
NEED_WITH_NSPR := 1
|
||||
else
|
||||
ifneq ("$(wildcard /usr/lib/libnspr3*)","")
|
||||
NSPR_INSTALL_DIR := /usr
|
||||
else
|
||||
NSPR_INSTALL_DIR := $(OBJDIR)/nspr
|
||||
NEED_WITH_NSPR := 1
|
||||
endif
|
||||
# these options can be overriden by the user
|
||||
ifndef NSPR_INSTALL_DIR
|
||||
NSPR_INSTALL_DIR = $(OBJDIR)/nspr
|
||||
endif
|
||||
|
||||
ifndef NSPR_OPTIONS
|
||||
NSPR_OPTIONS := NS_USE_GCC=1 NS_USE_NATIVE= $(NSPR_PTHREAD_FLAG)
|
||||
NSPR_OPTIONS = NS_USE_GCC=1 NS_USE_NATIVE=
|
||||
endif
|
||||
|
||||
# These options are required to make this makefile build NSPR correctly
|
||||
NSPR_REQ_OPTIONS := MOZILLA_CLIENT=1 NO_MDUPDATE=1
|
||||
NSPR_DIST_OPTION := DIST=$(NSPR_INSTALL_DIR) NSDISTMODE=copy
|
||||
NSPR_TARGET := export
|
||||
# these options are required to make this makefile build NSPR correctly
|
||||
NSPR_REQ_OPTIONS = MOZILLA_CLIENT=1 NO_MDUPDATE=1
|
||||
NSPR_DIST_OPTION = DIST=$(NSPR_INSTALL_DIR) NSDISTMODE=copy
|
||||
NSPR_TARGET = export
|
||||
|
||||
NSPR_GMAKE_OPTIONS := \
|
||||
$(NSPR_DIST_OPTION) \
|
||||
$(NSPR_REQ_OPTIONS) \
|
||||
$(NSPR_OPTIONS) \
|
||||
$(NSPR_TARGET)
|
||||
NSPR_GMAKE_OPTIONS = $(NSPR_DIST_OPTION) $(NSPR_REQ_OPTIONS) $(NSPR_OPTIONS) $(NSPR_TARGET)
|
||||
|
||||
#
|
||||
# Step 3: autoconf
|
||||
#
|
||||
# add new autoconf/configure flags here in the form:
|
||||
# ifdef MOZ_FLAGNAME
|
||||
# CONFIG_FLAGNAME_FLAG = --some-config-option=$(MOZ_FLAGNAME)
|
||||
# endif
|
||||
# then:
|
||||
# - DOCUMENT THE NEW OPTION ABOVE!
|
||||
# - add $(CONFIG_FLAGNAME_FLAG) to CONFIG_FLAGS at the bottom
|
||||
|
||||
CONFIG_FLAGS :=
|
||||
# default object directory, e.g. obj-sparc-sun-solaris2.5.1
|
||||
|
||||
ifdef NEED_WITH_NSPR
|
||||
CONFIG_FLAGS += --with-nspr=$(NSPR_INSTALL_DIR)
|
||||
ifdef MOZ_TOOLKIT
|
||||
CONFIG_TOOLKIT_FLAG = --enable-toolkit=$(MOZ_TOOLKIT)
|
||||
endif
|
||||
|
||||
ifeq "$(origin MOZ_WITH_PTHREADS)" "environment"
|
||||
CONFIG_FLAGS += --with-pthreads
|
||||
endif
|
||||
CONFIG_NSPR_FLAG = --with-nspr=$(NSPR_INSTALL_DIR)
|
||||
|
||||
# Enable editor ... might want to do this conditionally
|
||||
CONFIG_EDITOR_FLAG = --enable-editor
|
||||
|
||||
# Turn on debug:
|
||||
DEBUG_FLAG = --enable-debug
|
||||
|
||||
CONFIG_FLAGS = $(CONFIG_TOOLKIT_FLAG) $(CONFIG_NSPR_FLAG) $(CONFIG_EDITOR_FLAG)
|
||||
|
||||
#
|
||||
# Rules
|
||||
# rules
|
||||
#
|
||||
|
||||
all: checkout build
|
||||
all: checkout
|
||||
|
||||
.PHONY: checkout nspr build clean realclean
|
||||
|
||||
# Windows equivalents
|
||||
pull_all: checkout
|
||||
build_all: build
|
||||
clobber: clean
|
||||
clobber_all: realclean
|
||||
pull_and_build_all: checkout build
|
||||
.PHONY: checkout
|
||||
|
||||
#
|
||||
# CVS checkout
|
||||
#
|
||||
checkout:
|
||||
@if test -f $(CVSCO_LOGFILE) ; then \
|
||||
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
|
||||
else true; \
|
||||
fi
|
||||
@date > $(CVSCO_LOGFILE)
|
||||
cd $(ROOTDIR) && \
|
||||
$(CVSCO) $(MOZ_CO_MODULE) 2>&1 | tee -a $(CVSCO_LOGFILE)
|
||||
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
|
||||
if test "$$conflicts" ; then \
|
||||
echo "$(MAKE): *** Conflicts during checkout." ;\
|
||||
echo "$$conflicts" ;\
|
||||
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
|
||||
exit 1; \
|
||||
else true; \
|
||||
fi
|
||||
# Build the client.
|
||||
$(CVSCO) SeaMonkeyEditor
|
||||
|
||||
#
|
||||
# Web configure
|
||||
# build it
|
||||
#
|
||||
MOZCONFIG2URL := build/autoconf/mozconfig2url.sh
|
||||
webconfig:
|
||||
@url=$(WEBCONFIG_URL); \
|
||||
if test -f $(WEBCONFIG_FILE) ; then \
|
||||
cd $(TOPSRCDIR); \
|
||||
if test ! -f $(MOZCONFIG2URL); then \
|
||||
(cd ..; cvs co mozilla/$(MOZCONFIG2URL) mozilla/$(FIND_MOZCONFIG);) \
|
||||
else true; \
|
||||
fi; \
|
||||
url=$$url`$(MOZCONFIG2URL)`; \
|
||||
else true; \
|
||||
fi; \
|
||||
echo Running netscape with the following url: ;\
|
||||
echo ;\
|
||||
echo $$url ;\
|
||||
netscape -remote "openURL($$url)" || netscape $$url ;\
|
||||
echo ;\
|
||||
echo Fill out the form on the browser. ;\
|
||||
echo Save the results to $(WEBCONFIG_FILE) when done.
|
||||
|
||||
# netscape -remote "saveAs($(WEBCONFIG_FILE))"
|
||||
|
||||
ifdef IS_FIRST_CHECKOUT
|
||||
# First time, do build target in a new process to pick up new files.
|
||||
build:
|
||||
$(MAKE) -f $(TOPSRCDIR)/client.mk build
|
||||
else
|
||||
|
||||
#
|
||||
# Configure
|
||||
#
|
||||
|
||||
CONFIG_STATUS := $(wildcard $(OBJDIR)/config.status)
|
||||
CONFIG_CACHE := $(wildcard $(OBJDIR)/config.cache)
|
||||
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
EXTRA_CONFIG_DEPS := \
|
||||
$(TOPSRCDIR)/aclocal.m4 \
|
||||
$(TOPSRCDIR)/build/autoconf/gtk.m4 \
|
||||
$(TOPSRCDIR)/build/autoconf/altoptions.m4 \
|
||||
$(NULL)
|
||||
|
||||
$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
|
||||
# configure.in -> configure using autoconf
|
||||
$(SRCDIR)/configure: $(SRCDIR)/configure.in
|
||||
@echo Generating $@ using autoconf
|
||||
cd $(TOPSRCDIR); $(AUTOCONF)
|
||||
endif
|
||||
(cd $(SRCDIR); $(AUTOCONF))
|
||||
|
||||
$(OBJDIR)/Makefile: $(TOPSRCDIR)/configure $(TOPSRCDIR)/allmakefiles.sh $(TOPSRCDIR)/.client-defs.mk
|
||||
@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
|
||||
@echo cd $(OBJDIR);
|
||||
@echo LD_LIBRARY_PATH=$(MOZ_WITH_NSPR)/lib:$(LD_LIBRARY_PATH) \\
|
||||
@echo ../configure $(CONFIG_FLAGS)
|
||||
@cd $(OBJDIR) && \
|
||||
LD_LIBRARY_PATH=$(MOZ_WITH_NSPR)/lib:$(LD_LIBRARY_PATH) \
|
||||
$(TOPSRCDIR)/configure $(CONFIG_FLAGS) \
|
||||
|| echo Fix above errors and then restart with \"$(MAKE) -f client.mk build\"
|
||||
# configure -> Makefile by running 'configure'
|
||||
$(OBJDIR)/Makefile: $(SRCDIR)/configure
|
||||
@echo Determining configuration to generate $@
|
||||
-$(MKDIR) $(OBJDIR)
|
||||
(cd $(OBJDIR) ; LD_LIBRARY_PATH=$(NSPR_INSTALL_DIR)/lib:$(LD_LIBRARY_PATH) $(SRCDIR)/configure $(CONFIG_FLAGS))
|
||||
|
||||
ifdef CONFIG_STATUS
|
||||
$(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
|
||||
cd $(OBJDIR); \
|
||||
CONFIG_FILES=config/autoconf.mk ./config.status
|
||||
endif
|
||||
build: $(OBJDIR)/Makefile
|
||||
(cd $(OBJDIR); $(MAKE));
|
||||
|
||||
#
|
||||
# Build it
|
||||
#
|
||||
|
||||
build: nspr $(OBJDIR)/Makefile
|
||||
cd $(OBJDIR); $(MAKE);
|
||||
|
||||
# Build & install nspr. Classic build, no autoconf.
|
||||
# Linux/RPM available.
|
||||
nspr: $(NSPR_INSTALL_DIR)/lib/libnspr3.so
|
||||
@echo NSPR is installed in $(NSPR_INSTALL_DIR)/lib objdir=$(OBJDIR)
|
||||
nspr: $(NSPR_INSTALL_DIR)/lib/libnspr21.so
|
||||
@echo NSPR is ready and installed in $(NSPR_INSTALL_DIR)
|
||||
|
||||
$(NSPR_INSTALL_DIR)/lib/libnspr3.so:
|
||||
$(NSPR_INSTALL_DIR)/lib/libnspr21.so:
|
||||
$(CVSCO) -rNSPRPUB_RELEASE_3_0 NSPR
|
||||
@-$(MKDIR) -p $(NSPR_INSTALL_DIR)
|
||||
($(MAKE) -C $(TOPSRCDIR)/nsprpub $(NSPR_GMAKE_OPTIONS))
|
||||
($(MAKE) -C $(SRCDIR)/nsprpub $(NSPR_GMAKE_OPTIONS))
|
||||
|
||||
# NSPR is pulled by SeaMonkeyEditor module
|
||||
# cd $(ROOTDIR) && $(CVSCO) $(NSPR_BRANCH) NSPR
|
||||
|
||||
# Pass these target onto the real build system
|
||||
clean realclean:
|
||||
cd $(OBJDIR); $(MAKE) $@;
|
||||
|
||||
# (! IS_FIRST_CHECKOUT)
|
||||
endif
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// CIconCache.h
|
||||
// Mike Pinkerton, Netscape Communications
|
||||
//
|
||||
// Contains the implementation of the CImageCache class which is a small cache of
|
||||
// images which the FE can pull from with a low overhead. It's good for things
|
||||
// such as using images for icons in the chrome. Note that this is very
|
||||
// different from the XP image cache.
|
||||
//
|
||||
// The filename is old, owing back to the original name for this class, CIconCache
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "CIconContext.h"
|
||||
#include "il_types.h"
|
||||
#include "mimages.h"
|
||||
|
||||
|
||||
//
|
||||
// class ImageCacheData
|
||||
//
|
||||
// Contains all the relevant data for an image loaded from a url (not an FE icon). The
|
||||
// context controls the loading and notification of when the image has been loaded
|
||||
// and keeps copies of the FE pixmap data so when imageLib cleans house, we're still ok.
|
||||
//
|
||||
class ImageCacheData : public LBroadcaster {
|
||||
public:
|
||||
ImageCacheData ( const string & inURL ) ;
|
||||
~ImageCacheData ( ) ;
|
||||
|
||||
// Hold on tight to whatever we need to draw, making copies if necessary.
|
||||
void CacheThese ( IL_Pixmap* inImage, IL_Pixmap* inMask ) ;
|
||||
|
||||
CIconContext* IconContext ( ) const { return mContext; } ;
|
||||
void IconContextHasGoneAway ( ) { mContext = NULL; } ;
|
||||
|
||||
bool ImageAvailable ( ) { return mImage != NULL; } ;
|
||||
|
||||
NS_PixMap* Image ( ) const { return mImage; }
|
||||
NS_PixMap* Mask ( ) const { return mMask; }
|
||||
|
||||
private:
|
||||
|
||||
// declare these as private so no one can do them.
|
||||
ImageCacheData ( const ImageCacheData & ) ;
|
||||
ImageCacheData & operator= ( const ImageCacheData & ) ;
|
||||
|
||||
NS_PixMap* mImage;
|
||||
NS_PixMap* mMask;
|
||||
|
||||
CIconContext* mContext;
|
||||
|
||||
}; // struct ImageCacheData
|
||||
|
||||
|
||||
//
|
||||
// class CImageCache
|
||||
//
|
||||
// There should only be one of these in the entire application. Users make a request
|
||||
// by asking the cache for a particular URL. If the URL is not loaded, a new icon context
|
||||
// will be created and the caller will be placed on a list of listeners for when that
|
||||
// image is ready to draw. If the image has already been loaded, the caller will either
|
||||
// be placed on that listener list (for animating images) or be given the data directly
|
||||
// (for static images).
|
||||
//
|
||||
class CImageCache : public LListener
|
||||
{
|
||||
public:
|
||||
enum ELoadResult { kDataPresent, kPutOnWaitingList, kEmptyURL } ;
|
||||
|
||||
CImageCache ( ) ;
|
||||
virtual ~CImageCache ( ) ;
|
||||
|
||||
// Make a request for an icon. Will start loading if not present. If an
|
||||
// empty string is passed in, this will return |kEmptyURL| and nothing
|
||||
// will be loaded.
|
||||
ELoadResult RequestIcon ( const string & inURL, const LListener* inClient ) ;
|
||||
|
||||
// For images that are already loaded (RequestIcon() returned |kDataPresent|,
|
||||
// get the data.
|
||||
void FetchImageData ( const string & inURL, NS_PixMap** outImage, NS_PixMap** outMask ) ;
|
||||
|
||||
// Housecleaning. When a static image is finished, the context should go away
|
||||
// but the data should remain.
|
||||
void ContextFinished ( const MWContext* inContext ) ;
|
||||
|
||||
// a view might be going away before an image is finished loading. If that is
|
||||
// the case, it needs to be removed from the context's listener list so we don't
|
||||
// go telling dead objects their image has arrived.
|
||||
void ListenerGoingAway ( const string & inURL, LListener* inObjectGoingAway ) ;
|
||||
|
||||
private:
|
||||
|
||||
// declare these private so no one can make a copy of the cache
|
||||
CImageCache ( const CImageCache & ) ;
|
||||
CImageCache & operator= ( const CImageCache & ) ;
|
||||
|
||||
void ListenToMessage ( MessageT inMessage, void* inData ) ;
|
||||
|
||||
// clean out the cache when it gets too big.
|
||||
void Flush() ;
|
||||
|
||||
map<string, ImageCacheData*> mCache;
|
||||
|
||||
}; // class CImageCache
|
||||
|
||||
|
||||
// global declaration of our icon cache
|
||||
CImageCache& gImageCache ( ) ;
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
Evaluate % = ("{{SourceFile}}" =~ /(Å:)¨0Å/)
|
||||
|
||||
MakeStub "{{SourceFile}}" -o "{{¨0}}::::dist:client_stubs:NavigatorStubs" ¶
|
||||
-fragname Navigator ¶
|
||||
-vercur 400 -verdef 400 -verimp 400
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
# export debugging functions
|
||||
#{code}
|
||||
NOT_NULL
|
||||
XP_TraceInit
|
||||
FE_Trace
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
Evaluate % = ("{{SourceFile}}" =~ /(Å:)¨0Å/)
|
||||
|
||||
MakeStub "{{SourceFile}}" -o "{{¨0}}::::dist:client_stubs:NavigatorDebugExtras" ¶
|
||||
-fragname Navigator ¶
|
||||
-vercur 400 -verdef 400 -verimp 400
|
||||
Binary file not shown.
@@ -1,33 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
The one and only job of this project is to provide dummy
|
||||
libraries for the main project, when you are doing a build
|
||||
with some components turned off.
|
||||
|
||||
For example, if you compile MOZ_LITE, there is no editor.
|
||||
But to avoid having to have multiple targets in the final
|
||||
project, we just provide a stub library from here, to
|
||||
keep the IDE happy.
|
||||
|
||||
There will be one target for each dummy library that we
|
||||
need.
|
||||
*/
|
||||
|
||||
void NuthinToDo(void) {}
|
||||
Binary file not shown.
@@ -1,65 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* CAutoPtr.h */
|
||||
|
||||
|
||||
#ifndef CAutoPtr_H
|
||||
#define CAutoPtr_H
|
||||
#pragma once
|
||||
|
||||
template<class T>
|
||||
class CAutoPtr
|
||||
{
|
||||
public:
|
||||
CAutoPtr(T* p = 0) : p_(p) { }
|
||||
|
||||
CAutoPtr(const CAutoPtr& r) : p_(r.release()) { }
|
||||
|
||||
~CAutoPtr() { delete p_; }
|
||||
|
||||
CAutoPtr& operator = (const CAutoPtr& r) {
|
||||
if ((void *)&r != (void *) this) {
|
||||
delete p_;
|
||||
p_ = r.release();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& operator*(void) const{ return *p_; }
|
||||
|
||||
T* operator->(void) const { return p_; }
|
||||
|
||||
T* get(void) const { return p_; }
|
||||
|
||||
void reset(T* p = 0) {
|
||||
delete p_;
|
||||
p_ = p;
|
||||
}
|
||||
|
||||
T* release(void) const {
|
||||
T* old = p_;
|
||||
const_cast<CAutoPtr*>(this)->p_ = 0;
|
||||
return old;
|
||||
}
|
||||
|
||||
private:
|
||||
T* p_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* CAutoPtrXP.h */
|
||||
|
||||
#ifndef CAutoPtrXP_H
|
||||
#define CAutoPtrXP_H
|
||||
#pragma once
|
||||
|
||||
#include "xp_mem.h"
|
||||
|
||||
template<class T>
|
||||
class CAutoPtrXP
|
||||
{
|
||||
public:
|
||||
CAutoPtrXP(T* p = 0) : p_(p) { }
|
||||
|
||||
CAutoPtrXP(const CAutoPtrXP& r) : p_(r.release()) { }
|
||||
|
||||
~CAutoPtrXP() {
|
||||
if (p_)
|
||||
{
|
||||
XP_FREE(p_);
|
||||
}
|
||||
}
|
||||
|
||||
CAutoPtrXP& operator = (const CAutoPtrXP& r) {
|
||||
if ((void *)&r != (void *) this) {
|
||||
if (p_)
|
||||
{
|
||||
XP_FREE(p_);
|
||||
}
|
||||
p_ = r.release();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& operator*(void) const{ return *p_; }
|
||||
|
||||
T* operator->(void) const { return p_; }
|
||||
|
||||
T* get(void) const { return p_; }
|
||||
|
||||
void reset(T* p = 0) {
|
||||
if (p_)
|
||||
{
|
||||
XP_FREE(p_);
|
||||
}
|
||||
p_ = p;
|
||||
}
|
||||
|
||||
T* release() const {
|
||||
T* old = p_;
|
||||
const_cast<CAutoPtrXP*>(this)->p_ = 0;
|
||||
return old;
|
||||
}
|
||||
|
||||
private:
|
||||
T* p_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// ===========================================================================
|
||||
// CDefaultFontFontSwitcher.cp
|
||||
// ===========================================================================
|
||||
//
|
||||
// Authror: Frank Tang ftang@netscape.com
|
||||
#include "CDefaultFontFontSwitcher.h"
|
||||
#include "uintl.h"
|
||||
|
||||
INTL_Encoding_ID CDefaultFontFontSwitcher::gEncodingOfDefaultFont = 0;
|
||||
|
||||
CDefaultFontFontSwitcher::CDefaultFontFontSwitcher(UFontSwitcher* delegate)
|
||||
{
|
||||
GrafPtr port;
|
||||
::GetPort(&port);
|
||||
mDefaultFont = port->txFont;
|
||||
if(0 == gEncodingOfDefaultFont)
|
||||
{
|
||||
gEncodingOfDefaultFont = ScriptToEncoding(::GetScriptManagerVariable( smSysScript ) );
|
||||
}
|
||||
mDelegate = delegate;
|
||||
|
||||
}
|
||||
void CDefaultFontFontSwitcher::EncodingTextFont(INTL_Encoding_ID encoding)
|
||||
{
|
||||
if(gEncodingOfDefaultFont == encoding)
|
||||
::TextFont(mDefaultFont);
|
||||
else
|
||||
mDelegate->EncodingTextFont(encoding);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// ===========================================================================
|
||||
// CDefaultFontFontSwitcher.h
|
||||
// ===========================================================================
|
||||
//
|
||||
// Authror: Frank Tang ftang@netscape.com
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
CDefaultFontFontSwitcher
|
||||
Class know how to switch font depend on CPrefs:CCharSet
|
||||
*/
|
||||
#pragma once
|
||||
#include "UPropFontSwitcher.h"
|
||||
|
||||
class CDefaultFontFontSwitcher : public UFontSwitcher {
|
||||
|
||||
public:
|
||||
virtual void EncodingTextFont(INTL_Encoding_ID encoding);
|
||||
CDefaultFontFontSwitcher(UFontSwitcher* delegate);
|
||||
void RestoreDefaultFont() {::TextFont(mDefaultFont); }
|
||||
private:
|
||||
static INTL_Encoding_ID gEncodingOfDefaultFont;
|
||||
UFontSwitcher* mDelegate;
|
||||
short mDefaultFont;
|
||||
};
|
||||
@@ -1,50 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// CLibMsgPeriodical.cp
|
||||
|
||||
#include "CLibMsgPeriodical.h"
|
||||
#include "msgcom.h"
|
||||
|
||||
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
||||
// ¥¥¥
|
||||
// ¥ Class CLibMsgPeriodical
|
||||
// ¥¥¥
|
||||
//
|
||||
// This is a subclass of LPeriodical which calls the new libmsg init, exit,
|
||||
// and idle routines.
|
||||
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
||||
|
||||
CLibMsgPeriodical::CLibMsgPeriodical() :
|
||||
LPeriodical()
|
||||
{
|
||||
MSG_InitMsgLib();
|
||||
|
||||
/* use less memory! */
|
||||
MSG_SetDBCacheSize ( 512 * 1024L );
|
||||
}
|
||||
|
||||
CLibMsgPeriodical::~CLibMsgPeriodical()
|
||||
{
|
||||
MSG_ShutdownMsgLib();
|
||||
}
|
||||
|
||||
void CLibMsgPeriodical::SpendTime(const EventRecord& /* inMacEvent */)
|
||||
{
|
||||
MSG_OnIdle();
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// CLibMsgPeriodical.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LPeriodical.h>
|
||||
|
||||
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
||||
// ¥¥¥
|
||||
// ¥ Class CLibMsgPeriodical
|
||||
// ¥¥¥
|
||||
//
|
||||
// This is a subclass of LThread which calls the new libmsg init, exit, and
|
||||
// idle routines. Since we have to call an idle time routine, it seems like
|
||||
// this would be a good candidate to be in a thread
|
||||
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
||||
|
||||
class CLibMsgPeriodical : public LPeriodical
|
||||
{
|
||||
public:
|
||||
CLibMsgPeriodical();
|
||||
virtual ~CLibMsgPeriodical();
|
||||
|
||||
protected:
|
||||
virtual void SpendTime(const EventRecord& inMacEvent);
|
||||
};
|
||||
@@ -1,54 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// CLibMsgThread.cp
|
||||
|
||||
|
||||
#include "CLibMsgThread.h"
|
||||
#include "msgcom.h"
|
||||
|
||||
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
||||
// ¥¥¥
|
||||
// ¥ Class CLibMsgThread
|
||||
// ¥¥¥
|
||||
//
|
||||
// This is a subclass of LThread which calls the new libmsg init, exit, and
|
||||
// idle routines. Since we have to call an idle time routine, it seems like
|
||||
// this would be a good candidate as any to be in a thread
|
||||
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
||||
|
||||
CLibMsgThread::CLibMsgThread() :
|
||||
LThread(false)
|
||||
{
|
||||
MSG_InitMsgLib();
|
||||
}
|
||||
|
||||
CLibMsgThread::~CLibMsgThread()
|
||||
{
|
||||
MSG_ShutdownMsgLib();
|
||||
}
|
||||
|
||||
void *CLibMsgThread::Run()
|
||||
{
|
||||
while(true) {
|
||||
LThread::Yield();
|
||||
MSG_OnIdle();
|
||||
LThread::Yield();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// CLibMsgThread.h
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LThread.h>
|
||||
|
||||
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
||||
// ¥¥¥
|
||||
// ¥ Class CLibMsgThread
|
||||
// ¥¥¥
|
||||
//
|
||||
// This is a subclass of LThread which calls the new libmsg init, exit, and
|
||||
// idle routines. Since we have to call an idle time routine, it seems like
|
||||
// this would be a good candidate to be in a thread
|
||||
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
||||
|
||||
class CLibMsgThread : public LThread
|
||||
{
|
||||
public:
|
||||
CLibMsgThread();
|
||||
virtual ~CLibMsgThread();
|
||||
|
||||
protected:
|
||||
virtual void* Run();
|
||||
};
|
||||
@@ -1,388 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*======================================================================================
|
||||
AUTHOR: Ted Morris <tmorris@netscape.com> - 08 NOV 96
|
||||
|
||||
MODIFICATIONS:
|
||||
|
||||
Date Person Description
|
||||
---- ------ -----------
|
||||
======================================================================================*/
|
||||
|
||||
|
||||
/*====================================================================================*/
|
||||
#pragma mark INCLUDE FILES
|
||||
/*====================================================================================*/
|
||||
|
||||
#include "CSaveWindowStatus.h"
|
||||
|
||||
#include "uprefd.h"
|
||||
#include "macutil.h"
|
||||
|
||||
|
||||
#pragma mark -
|
||||
/*====================================================================================*/
|
||||
#pragma mark TYPEDEFS
|
||||
/*====================================================================================*/
|
||||
|
||||
|
||||
#pragma mark -
|
||||
/*====================================================================================*/
|
||||
#pragma mark CONSTANTS
|
||||
/*====================================================================================*/
|
||||
|
||||
|
||||
#pragma mark -
|
||||
/*====================================================================================*/
|
||||
#pragma mark INTERNAL FUNCTION PROTOTYPES
|
||||
/*====================================================================================*/
|
||||
|
||||
|
||||
#pragma mark -
|
||||
/*====================================================================================*/
|
||||
#pragma mark INTERNAL CLASS DECLARATIONS
|
||||
/*====================================================================================*/
|
||||
|
||||
|
||||
#pragma mark -
|
||||
/*====================================================================================*/
|
||||
#pragma mark CLASS IMPLEMENTATIONS
|
||||
/*====================================================================================*/
|
||||
|
||||
#pragma mark -
|
||||
/*======================================================================================
|
||||
Find the global bounds for the pane.
|
||||
======================================================================================*/
|
||||
|
||||
void CSaveWindowStatus::GetPaneGlobalBounds(LPane *inPane, Rect *outBounds) {
|
||||
|
||||
inPane->CalcPortFrameRect(*outBounds);
|
||||
inPane->PortToGlobalPoint(topLeft(*outBounds));
|
||||
inPane->PortToGlobalPoint(botRight(*outBounds));
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================================
|
||||
Move this window to an alert position on the main screen.
|
||||
======================================================================================*/
|
||||
|
||||
void CSaveWindowStatus::MoveWindowToAlertPosition(LWindow *inWindow) {
|
||||
|
||||
Rect bounds;
|
||||
|
||||
GetPaneGlobalBounds(inWindow, &bounds);
|
||||
|
||||
GDHandle dominantDevice;
|
||||
LWindow *frontWindowP = UDesktop::FetchTopRegular();
|
||||
|
||||
if ( frontWindowP ) {
|
||||
dominantDevice = UWindows::FindDominantDevice(
|
||||
UWindows::GetWindowStructureRect(frontWindowP->GetMacPort()));
|
||||
} else {
|
||||
dominantDevice = ::GetMainDevice();
|
||||
}
|
||||
|
||||
Rect screenRect = (**dominantDevice).gdRect;
|
||||
if ( dominantDevice == ::GetMainDevice() ) {
|
||||
screenRect.top += GetMBarHeight();
|
||||
}
|
||||
|
||||
::OffsetRect(&bounds, screenRect.left + ((screenRect.right - screenRect.left - (bounds.right - bounds.left)) / 2) - bounds.left,
|
||||
screenRect.top + ((screenRect.bottom - screenRect.top - (bounds.bottom - bounds.top)) / 3) - bounds.top);
|
||||
|
||||
inWindow->DoSetBounds(bounds);
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================================
|
||||
Move this window to a new position on the main screen.
|
||||
======================================================================================*/
|
||||
|
||||
void CSaveWindowStatus::MoveWindowTo(LWindow *inWindow, Point inGlobalTopLeft) {
|
||||
|
||||
Rect bounds;
|
||||
GetPaneGlobalBounds(inWindow, &bounds);
|
||||
|
||||
::OffsetRect(&bounds, inGlobalTopLeft.h - bounds.left,
|
||||
inGlobalTopLeft.v - bounds.top);
|
||||
|
||||
VerifyWindowBounds(inWindow, &bounds);
|
||||
inWindow->DoSetBounds(bounds);
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================================
|
||||
Verify the specified bounds against the window min/max sizes and the desktop
|
||||
bounds.
|
||||
======================================================================================*/
|
||||
static
|
||||
inline
|
||||
Int16
|
||||
pin( const Int16& lo, const Int16& x, const Int16& hi )
|
||||
{
|
||||
return (x<lo) ? lo : ((hi<x) ? hi : x);
|
||||
}
|
||||
|
||||
|
||||
void CSaveWindowStatus::VerifyWindowBounds(LWindow *inWindow, Rect *ioGlobalBounds)
|
||||
/*
|
||||
Make sure the entire window is on-screen [for roughly rectangular desktops].
|
||||
|
||||
|ioGlobalBounds| is the proposed content rect of the window, in global coordinates. It
|
||||
is not necessarily related to the current actual content rect of the window.
|
||||
*/
|
||||
{
|
||||
/*
|
||||
First, calculate the rectangle within which the windows content rect must fit,
|
||||
for that window to be entirely on-screen. Note: we explicitly don't handle the
|
||||
Ôfunny desktopÕ case. This may be required.
|
||||
*/
|
||||
Int16 desktopMinTop, desktopMaxBottom, desktopMaxWidth;
|
||||
Int16 desktopMinLeft, desktopMaxRight, desktopMaxHeight;
|
||||
{
|
||||
// The bounding box of Ôthe gray regionÕ is the rectangle we want our window to fit entirely within.
|
||||
Rect desktopRect = (**::GetGrayRgn()).rgnBBox;
|
||||
|
||||
// Calculate how much the windows structure region ÔpadsÕ its content region...
|
||||
Rect structureRect = UWindows::GetWindowStructureRect(inWindow->GetMacPort());
|
||||
Rect contentRect = UWindows::GetWindowContentRect(inWindow->GetMacPort());
|
||||
|
||||
Int16 topPadding = contentRect.top - structureRect.top;
|
||||
Int16 bottomPadding = structureRect.bottom - contentRect.bottom;
|
||||
Int16 leftPadding = contentRect.left - structureRect.left;
|
||||
Int16 rightPadding = structureRect.right - contentRect.right;
|
||||
|
||||
// ...and shrink |desktopRect| accordingly (so it is relative to our content rect, instead of our structure rect).
|
||||
desktopRect.top += cWindowDesktopMargin + topPadding;
|
||||
desktopRect.bottom -= cWindowDesktopMargin + bottomPadding;
|
||||
desktopRect.left += cWindowDesktopMargin + leftPadding;
|
||||
desktopRect.right -= cWindowDesktopMargin + rightPadding;
|
||||
|
||||
desktopMinTop = desktopRect.top; // windows content rect top must not be above this this
|
||||
desktopMaxBottom = desktopRect.bottom; // ...nor its bottom below this
|
||||
desktopMaxHeight = desktopMaxBottom - desktopMinTop; // ...nor its height greater than this
|
||||
|
||||
desktopMinLeft = desktopRect.left; // ...
|
||||
desktopMaxRight = desktopRect.right;
|
||||
desktopMaxWidth = desktopMaxRight - desktopMinLeft;
|
||||
}
|
||||
|
||||
/*
|
||||
Second, calculate the minimum and maximum size of the window based on its own min/max settings
|
||||
and the limits imposed by the screen.
|
||||
*/
|
||||
Int16 minHeight, maxHeight, minWidth, maxWidth;
|
||||
{
|
||||
Rect windowLimits;
|
||||
inWindow->GetMinMaxSize(windowLimits);
|
||||
|
||||
minHeight = pin(0, windowLimits.top, desktopMaxHeight);
|
||||
maxHeight = pin(minHeight, windowLimits.bottom, desktopMaxHeight);
|
||||
minWidth = pin(0, windowLimits.left, desktopMaxWidth);
|
||||
maxWidth = pin(minWidth, windowLimits.right, desktopMaxWidth);
|
||||
}
|
||||
|
||||
/*
|
||||
Third, pin the windows size to its calculated limits.
|
||||
*/
|
||||
Int16 height = pin(minHeight, ioGlobalBounds->bottom-ioGlobalBounds->top, maxHeight);
|
||||
Int16 width = pin(minWidth, ioGlobalBounds->right-ioGlobalBounds->left, maxWidth);
|
||||
|
||||
|
||||
/*
|
||||
Fourth (and finally), now that we know its size, pin its location onto the screen, and
|
||||
stuff the calculated results back into |ioGlobalBounds|.
|
||||
*/
|
||||
ioGlobalBounds->top = pin(desktopMinTop, ioGlobalBounds->top, desktopMaxBottom - height);
|
||||
ioGlobalBounds->left = pin(desktopMinLeft, ioGlobalBounds->left, desktopMaxRight - width);
|
||||
|
||||
ioGlobalBounds->bottom = ioGlobalBounds->top + height;
|
||||
ioGlobalBounds->right = ioGlobalBounds->left + width;
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================================
|
||||
Better create window with saved status ID.
|
||||
======================================================================================*/
|
||||
|
||||
LWindow *CSaveWindowStatus::CreateWindow(ResIDT inWindowID, LCommander *inSuperCommander) {
|
||||
|
||||
LCommander::SetDefaultCommander(inSuperCommander);
|
||||
LAttachable::SetDefaultAttachable(nil);
|
||||
|
||||
LWindow *theWindow = (LWindow *) UReanimator::ReadObjects('PPob', inWindowID);
|
||||
|
||||
try
|
||||
{
|
||||
FailNIL_(theWindow);
|
||||
theWindow->FinishCreate();
|
||||
if ( theWindow->HasAttribute(windAttr_ShowNew) ) {
|
||||
theWindow->Show();
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete theWindow;
|
||||
throw;
|
||||
}
|
||||
return theWindow;
|
||||
}
|
||||
|
||||
/*======================================================================================
|
||||
Do basic initialization of the window. Should be called from the window's
|
||||
FinishCreateSelf().
|
||||
======================================================================================*/
|
||||
|
||||
void CSaveWindowStatus::FinishCreateWindow()
|
||||
{
|
||||
Handle statusInfoH = CPrefs::ReadWindowData(GetStatusResID());
|
||||
Boolean doAdjustNIL = true;
|
||||
|
||||
try {
|
||||
|
||||
// Validate stored state info
|
||||
if ( statusInfoH ) {
|
||||
LHandleStream statusStream(statusInfoH);
|
||||
UInt16 bogusVersion, version;
|
||||
// As of 97/10/13, we are writing out zero as the first version data,
|
||||
// because Communicator 4.0x was checking version >= GetValidStatusVersion(),
|
||||
// and thus trying to decode future versions of the status, and crashing.
|
||||
statusStream >> bogusVersion; // and discard this zero.
|
||||
statusStream >> version;
|
||||
if ( bogusVersion == 0 && version == GetValidStatusVersion() ) {
|
||||
doAdjustNIL = false;
|
||||
ReadWindowStatus(&statusStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( ExceptionCode inErr) {
|
||||
|
||||
Assert_(false); // Just catch it, don't do anything!
|
||||
}
|
||||
catch ( OSErr inErr ) { } // probably bad status version. Again, do nothing
|
||||
|
||||
if ( doAdjustNIL ) ReadWindowStatus(nil);
|
||||
}
|
||||
|
||||
void CSaveWindowStatus::FinishCreateWindow(CSaveWindowStatus* inTemplateWindow)
|
||||
{
|
||||
ThrowIfNot_(inTemplateWindow->GetStatusResID() == GetStatusResID());
|
||||
ThrowIfNot_(inTemplateWindow->GetValidStatusVersion() == GetValidStatusVersion());
|
||||
LHandleStream statusStream;
|
||||
inTemplateWindow->WriteWindowStatus(&statusStream);
|
||||
statusStream.SetMarker(0, streamFrom_Start);
|
||||
this->ReadWindowStatus(&statusStream);
|
||||
// Stagger.
|
||||
Rect bounds;
|
||||
GetPaneGlobalBounds(mWindowSelf, &bounds);
|
||||
OffsetRect(&bounds, 20, 20);
|
||||
VerifyWindowBounds(mWindowSelf, &bounds);
|
||||
mWindowSelf->DoSetBounds(bounds);
|
||||
}
|
||||
|
||||
/*======================================================================================
|
||||
Try to close a Window as a result of direct user action. Save window status. Should
|
||||
be called from the window's AttemptClose() or DoClose() method as follows:
|
||||
|
||||
virtual void AttemptClose() {
|
||||
AttemptCloseWindow();
|
||||
inherited::AttemptClose();
|
||||
}
|
||||
virtual void DoClose() {
|
||||
AttemptCloseWindow();
|
||||
inherited::DoClose();
|
||||
}
|
||||
======================================================================================*/
|
||||
|
||||
void CSaveWindowStatus::AttemptCloseWindow() {
|
||||
|
||||
Assert_(mWindowSelf->GetSuperCommander() != nil);
|
||||
|
||||
if ( mWindowSelf->GetSuperCommander()->AllowSubRemoval(mWindowSelf) ) {
|
||||
SaveStatusInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================================
|
||||
Adjust the window to stored preferences. This method should be overriden in subclasses to
|
||||
read data from the stream as stored preferences. Make sure to call this method
|
||||
first.
|
||||
======================================================================================*/
|
||||
|
||||
void CSaveWindowStatus::ReadWindowStatus(LStream *inStatusData)
|
||||
{
|
||||
if ( inStatusData != nil )
|
||||
{
|
||||
mHasSavedStatus = true;
|
||||
|
||||
Rect bounds;
|
||||
*inStatusData >> bounds;
|
||||
VerifyWindowBounds(mWindowSelf, &bounds);
|
||||
mWindowSelf->DoSetBounds(bounds);
|
||||
}
|
||||
// Don't center the window in the default case, because not all clients
|
||||
// want this.
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================================
|
||||
Get window stored preferences. This method should be overriden in subclasses to
|
||||
write data to the stream that needs to be stored. Make sure to call this method
|
||||
first.
|
||||
======================================================================================*/
|
||||
|
||||
void CSaveWindowStatus::WriteWindowStatus(LStream *outStatusData)
|
||||
{
|
||||
mHasSavedStatus = true;
|
||||
|
||||
Rect bounds;
|
||||
GetPaneGlobalBounds(mWindowSelf, &bounds);
|
||||
|
||||
*outStatusData << bounds;
|
||||
}
|
||||
|
||||
|
||||
/*======================================================================================
|
||||
Store window preferences.
|
||||
======================================================================================*/
|
||||
|
||||
void CSaveWindowStatus::SaveStatusInfo()
|
||||
{
|
||||
if ( !mCanSaveStatus ) return;
|
||||
|
||||
try
|
||||
{
|
||||
LHandleStream statusStream;
|
||||
UInt16 bogusVersion = 0; // so that Communicator 4.0x will not use the data.
|
||||
statusStream << bogusVersion;
|
||||
statusStream << GetValidStatusVersion();
|
||||
|
||||
WriteWindowStatus(&statusStream);
|
||||
|
||||
CPrefs::WriteWindowData(statusStream.GetDataHandle(), GetStatusResID());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
||||
Assert_(false); // Just catch it, don't do anything!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __H_CSaveWindowStatus
|
||||
#define __H_CSaveWindowStatus
|
||||
#pragma once
|
||||
|
||||
/*======================================================================================
|
||||
AUTHOR: Ted Morris <tmorris@netscape.com> - 08 NOV 96
|
||||
|
||||
DESCRIPTION: Defines a mix-in class for saving a window's status to the preferences
|
||||
file.
|
||||
|
||||
MODIFICATIONS:
|
||||
|
||||
Date Person Description
|
||||
---- ------ -----------
|
||||
======================================================================================*/
|
||||
|
||||
|
||||
/*====================================================================================*/
|
||||
#pragma mark INCLUDE FILES
|
||||
/*====================================================================================*/
|
||||
|
||||
class LWindow;
|
||||
class LStream;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
/*====================================================================================*/
|
||||
#pragma mark CLASS DECLARATIONS
|
||||
/*====================================================================================*/
|
||||
|
||||
class CSaveWindowStatus {
|
||||
|
||||
public:
|
||||
|
||||
CSaveWindowStatus(LWindow *inWindow) {
|
||||
mWindowSelf = inWindow;
|
||||
mCanSaveStatus = true;
|
||||
mHasSavedStatus = false;
|
||||
Assert_(mWindowSelf != nil);
|
||||
}
|
||||
|
||||
Boolean CanSaveStatus() {
|
||||
return mCanSaveStatus;
|
||||
}
|
||||
void SetCanSaveStatus(Boolean inCanSave) {
|
||||
mCanSaveStatus = inCanSave;
|
||||
}
|
||||
|
||||
enum {
|
||||
cWindowDesktopMargin = 4
|
||||
, cMinSavedStatusSize = sizeof(Int16) + sizeof(Rect)
|
||||
};
|
||||
|
||||
static void GetPaneGlobalBounds(LPane *inPane, Rect *outBounds);
|
||||
static void MoveWindowToAlertPosition(LWindow *inWindow);
|
||||
static void MoveWindowTo(LWindow *inWindow, Point inGlobalTopLeft);
|
||||
static void VerifyWindowBounds(LWindow *inWindow, Rect *ioGlobalBounds);
|
||||
static LWindow *CreateWindow(ResIDT inWindowID, LCommander *inSuperCommander);
|
||||
|
||||
protected:
|
||||
|
||||
void FinishCreateWindow(); // from disk
|
||||
void FinishCreateWindow(CSaveWindowStatus* templateStatus);
|
||||
void AttemptCloseWindow();
|
||||
void SaveStatusInfo();
|
||||
|
||||
// It is only valid to call HasSavedStatus() after
|
||||
// the window has been properly created (i.e. after
|
||||
// calling FinishCreateWindow() ).
|
||||
|
||||
Boolean HasSavedStatus()
|
||||
{
|
||||
return mHasSavedStatus;
|
||||
}
|
||||
|
||||
virtual ResIDT GetStatusResID() const = 0; // client must provide!
|
||||
virtual UInt16 GetValidStatusVersion() const = 0; // client must provide!
|
||||
virtual void ReadWindowStatus(LStream *inStatusData);
|
||||
virtual void WriteWindowStatus(LStream *outStatusData);
|
||||
|
||||
LWindow *mWindowSelf;
|
||||
Boolean mCanSaveStatus;
|
||||
|
||||
private:
|
||||
Boolean mHasSavedStatus;
|
||||
};
|
||||
#endif // __H_CSaveWindowStatus
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "CStLayerOriginSetter.h"
|
||||
|
||||
// See header file for documentation
|
||||
|
||||
CStLayerOriginSetter::CStLayerOriginSetter(CHTMLView *viewToSet, CL_Layer *the_layer)
|
||||
: mShouldChange(false) {
|
||||
|
||||
mViewToSet = viewToSet;
|
||||
if (the_layer && mViewToSet) {
|
||||
mViewToSet->GetLayerOrigin(&mOldx, &mOldy);
|
||||
mViewToSet->SetLayerOrigin(CL_GetLayerXOrigin(the_layer), CL_GetLayerYOrigin(the_layer));
|
||||
mShouldChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
CStLayerOriginSetter::~CStLayerOriginSetter() {
|
||||
|
||||
if (mShouldChange && mViewToSet)
|
||||
mViewToSet->SetLayerOrigin(mOldx, mOldy);
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
CStLayerOriginSetter
|
||||
|
||||
This class is used to set the layer origin temporarily. For example, if you are dragging and
|
||||
dropping and want the origin to be changed to the item you're dragging, you would do (in
|
||||
CHTMLView):
|
||||
|
||||
|
||||
do stuff with old origin
|
||||
{
|
||||
CStOriginSetter setLayerOrigin(this, in_layer);
|
||||
do your dragging stuff with new origin
|
||||
}
|
||||
do other stuff with old origin
|
||||
|
||||
This class thus handles any exceptions, etc. that are done while doing stuff with the new
|
||||
origin.
|
||||
|
||||
NOTE: This class should never be subclassed.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CHTMLView.h"
|
||||
|
||||
class CStLayerOriginSetter {
|
||||
|
||||
public:
|
||||
CStLayerOriginSetter(CHTMLView *viewToSet, CL_Layer *the_layer);
|
||||
~CStLayerOriginSetter();
|
||||
|
||||
private:
|
||||
Int32 mOldx;
|
||||
Int32 mOldy;
|
||||
CHTMLView *mViewToSet;
|
||||
Boolean mShouldChange;
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
xp_file_mac.h
|
||||
@@ -1,981 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "MPreference.h"
|
||||
|
||||
#include "PascalString.h"
|
||||
|
||||
#include <LControl.h>
|
||||
#include <LGAPopup.h>
|
||||
#include <LGACaption.h>
|
||||
|
||||
#include "xp_mcom.h"
|
||||
#include "prefapi.h"
|
||||
#include "macutil.h" // for StringParamText
|
||||
#include "prefwutil.h" // for CColorButton
|
||||
|
||||
#include "StSetBroadcasting.h"
|
||||
#include "CTooltipAttachment.h"
|
||||
|
||||
Boolean MPreferenceBase::sWriteOnDestroy = false; // must be one for all instantiations of the template.
|
||||
Boolean MPreferenceBase::sUseTempPrefPrefix = false; // must be one for all instantiations of the template.
|
||||
char* MPreferenceBase::sReplacementString = nil;
|
||||
|
||||
const char * kTempPrefPrefix = "temp_pref_mac"; // prepended to the prefs string
|
||||
|
||||
//========================================================================================
|
||||
class CDebugPrefToolTipAttachment : public CToolTipAttachment
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
enum { class_ID = 'X%W@' };
|
||||
|
||||
CDebugPrefToolTipAttachment(MPreferenceBase* b);
|
||||
protected:
|
||||
virtual void CalcTipText(
|
||||
LWindow* inOwningWindow,
|
||||
LPane* inOwningPane,
|
||||
const EventRecord& inMacEvent,
|
||||
StringPtr outTipText);
|
||||
MPreferenceBase* mPreferenceBase;
|
||||
}; // class CDebugPrefToolTipAttachment
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDebugPrefToolTipAttachment::CDebugPrefToolTipAttachment(MPreferenceBase* b)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: CToolTipAttachment(60, 11507)
|
||||
, mPreferenceBase(b)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDebugPrefToolTipAttachment::CalcTipText(
|
||||
//----------------------------------------------------------------------------------------
|
||||
LWindow* /* inOwningWindow */,
|
||||
LPane* /* inOwningPane */,
|
||||
const EventRecord& /* inMacEvent */,
|
||||
StringPtr outTipText)
|
||||
{
|
||||
*(CStr255*)outTipText = mPreferenceBase->mName;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
//----------------------------------------------------------------------------------------
|
||||
MPreferenceBase::MPreferenceBase(
|
||||
LPane* inPane
|
||||
, LStream* inStream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mName(nil)
|
||||
, mSubstitutedName(nil)
|
||||
, mLocked(false)
|
||||
, mWritePref(true)
|
||||
, mPaneSelf(inPane)
|
||||
{
|
||||
CStr255 text;
|
||||
inStream->ReadPString(text);
|
||||
SetPrefName((const char*)text, false);
|
||||
*inStream >> mOrdinal;
|
||||
} // MPreferenceBase::MPreferenceBase
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
MPreferenceBase::~MPreferenceBase()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
XP_FREEIF(const_cast<char*>(mSubstitutedName));
|
||||
mSubstitutedName = nil;
|
||||
XP_FREEIF(const_cast<char*>(mName));
|
||||
mName = nil;
|
||||
} // MPreferenceBase::~MPreferenceBase
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreferenceBase::SetPrefName(const char* inNewName, Boolean inReread)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
/*
|
||||
const char* oldName = mName; // so that inNewName == mName works
|
||||
CStr255 text(inNewName);
|
||||
if (sReplacementString && *sReplacementString)
|
||||
::StringParamText(text, sReplacementString);
|
||||
|
||||
if (sUseTempPrefPrefix)
|
||||
{
|
||||
mName = XP_STRDUP(kTempPrefPrefix);
|
||||
StrAllocCat(mName, text);
|
||||
}
|
||||
else
|
||||
mName = XP_STRDUP((const char*)text);
|
||||
*/
|
||||
XP_FREEIF(const_cast<char *>(mName));
|
||||
mName = XP_STRDUP(inNewName);
|
||||
|
||||
if (inReread)
|
||||
{
|
||||
ReadLockState();
|
||||
ReadSelf();
|
||||
}
|
||||
} // MPreferenceBase::ReadLockState
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/*static*/ void MPreferenceBase::SetReplacementString(const char* s)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
XP_FREEIF(sReplacementString);
|
||||
sReplacementString = (s != nil) ? XP_STRDUP(s) : nil;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/*static*/ void MPreferenceBase::ChangePrefName(LView* inSuperView, PaneIDT inPaneID, const char* inNewName)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
LPane* p = inSuperView->FindPaneByID(inPaneID);
|
||||
MPreferenceBase* pb = dynamic_cast<MPreferenceBase*>(p);
|
||||
SignalIf_(!pb);
|
||||
if (pb)
|
||||
pb->SetPrefName(inNewName);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/*static*/ void MPreferenceBase::SetPaneWritePref(LView* inSuperView, PaneIDT inPaneID, Boolean inWritePref)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
LPane* p = inSuperView->FindPaneByID(inPaneID);
|
||||
MPreferenceBase* pb = dynamic_cast<MPreferenceBase*>(p);
|
||||
SignalIf_(!pb);
|
||||
if (pb)
|
||||
pb->SetWritePref(inWritePref);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/*static*/ const char* MPreferenceBase::GetPanePrefName(LView* inSuperView, PaneIDT inPaneID)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
LPane* p = inSuperView->FindPaneByID(inPaneID);
|
||||
MPreferenceBase* pb = dynamic_cast<MPreferenceBase*>(p);
|
||||
SignalIf_(!pb);
|
||||
if (pb)
|
||||
return XP_STRDUP(pb->GetPrefName());
|
||||
return nil;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/*static*/ const char* MPreferenceBase::GetPaneUnsubstitutedPrefName(LView* inSuperView, PaneIDT inPaneID)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
LPane* p = inSuperView->FindPaneByID(inPaneID);
|
||||
MPreferenceBase* pb = dynamic_cast<MPreferenceBase*>(p);
|
||||
SignalIf_(!pb);
|
||||
if (pb)
|
||||
return XP_STRDUP(pb->mName);
|
||||
return nil;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
const char* MPreferenceBase::GetPrefName()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CStr255 subName(mName);
|
||||
|
||||
if (sReplacementString && *sReplacementString)
|
||||
::StringParamText(subName, sReplacementString);
|
||||
|
||||
XP_FREEIF(const_cast<char *>(mSubstitutedName));
|
||||
|
||||
if (sUseTempPrefPrefix)
|
||||
{
|
||||
CStr255 newName(kTempPrefPrefix);
|
||||
newName += ".";
|
||||
newName += subName;
|
||||
|
||||
mSubstitutedName = XP_STRDUP(newName);
|
||||
}
|
||||
else
|
||||
mSubstitutedName = XP_STRDUP(subName);
|
||||
|
||||
return mSubstitutedName;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
const char* MPreferenceBase::GetValidPrefName()
|
||||
// Get the pref name, with or without the prefix depending on whether the prefixed
|
||||
// preference exists or not.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CStr255 subName(mName);
|
||||
|
||||
if (sReplacementString && *sReplacementString)
|
||||
::StringParamText(subName, sReplacementString);
|
||||
|
||||
XP_FREEIF(const_cast<char *>(mSubstitutedName));
|
||||
|
||||
if (sUseTempPrefPrefix)
|
||||
{
|
||||
CStr255 newName(kTempPrefPrefix);
|
||||
newName += ".";
|
||||
newName += subName;
|
||||
|
||||
if (PREF_GetPrefType(newName) == PREF_ERROR)
|
||||
mSubstitutedName = XP_STRDUP(subName); // the prefixed pref does not exist.
|
||||
else
|
||||
mSubstitutedName = XP_STRDUP(newName);
|
||||
}
|
||||
else
|
||||
mSubstitutedName = XP_STRDUP(subName);
|
||||
|
||||
return mSubstitutedName;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
const char* MPreferenceBase::GetUnsubstitutedPrefName()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return XP_STRDUP(mName);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreferenceBase::ReadLockState()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mLocked = PREF_PrefIsLocked(GetPrefName());
|
||||
if (mLocked)
|
||||
mPaneSelf->Disable();
|
||||
} // MPreferenceBase::ReadLockState
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreferenceBase::FinishCreate()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
ReadLockState();
|
||||
ReadSelf();
|
||||
#ifdef DEBUG
|
||||
LAttachable::SetDefaultAttachable(mPaneSelf);
|
||||
CDebugPrefToolTipAttachment* a = new CDebugPrefToolTipAttachment(this);
|
||||
mPaneSelf->AddAttachment(a);
|
||||
#endif
|
||||
} // MPreferenceBase::FinishCreate
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreferenceBase::ShouldWrite() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!sWriteOnDestroy || mLocked || !mWritePref)
|
||||
return false;
|
||||
|
||||
/*
|
||||
if (strstr(mName, "^0") != nil) // yow! unreplaced strings
|
||||
{
|
||||
// Check if a replacement has become possible
|
||||
Assert_(sReplacementString && *sReplacementString);
|
||||
if (!sReplacementString || !*sReplacementString)
|
||||
return false;
|
||||
const_cast<MPreferenceBase*>(this)->SetPrefName(mName, false); // don't read
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
// Note: don't worry about testing Changed(), since preflib does that.
|
||||
} // MPreferenceBase::ShouldWrite
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/*static*/ void MPreferenceBase::InitTempPrefCache()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// delete the temp pref tree
|
||||
PREF_DeleteBranch(kTempPrefPrefix);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/*static*/ void MPreferenceBase::CopyCachedPrefsToMainPrefs()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
int result;
|
||||
|
||||
result = PREF_CopyPrefsTree(kTempPrefPrefix, "");
|
||||
Assert_(result == PREF_NOERROR);
|
||||
|
||||
result = PREF_DeleteBranch(kTempPrefPrefix);
|
||||
Assert_(result == PREF_NOERROR);
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
//----------------------------------------------------------------------------------------
|
||||
template <class TPane, class TData> MPreference<TPane,TData>::MPreference(
|
||||
LPane* inPane,
|
||||
LStream* inStream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: MPreferenceBase(inPane, inStream)
|
||||
{
|
||||
} // MPreference::MPreference
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
template <class TPane, class TData> MPreference<TPane,TData>::~MPreference()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // MPreference::~MPreference
|
||||
|
||||
#pragma mark -
|
||||
|
||||
enum // what the ordinal means in this case:
|
||||
{
|
||||
kOrdinalXORBit = 1<<0
|
||||
, kOrdinalIntBit = 1<<1
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
XP_Bool MPreference<LControl,XP_Bool>::GetPaneValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return ((LControl*)mPaneSelf)->GetValue();
|
||||
} // MPreference<LControl,XP_Bool>::GetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,XP_Bool>::SetPaneValue(XP_Bool inData)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
((LControl*)mPaneSelf)->SetValue(inData);
|
||||
} // MPreference<LControl,XP_Bool>::SetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreference<LControl, XP_Bool>::Changed() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return GetPaneValue() != mInitialControlValue;
|
||||
} // MPreference<LControl,XP_Bool>::Changed
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,XP_Bool>::InitializeUsing(PrefReadFunc inFunc)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
XP_Bool value;
|
||||
int prefResult;
|
||||
if (mOrdinal & kOrdinalIntBit)
|
||||
{
|
||||
int32 intValue;
|
||||
typedef int (*IntPrefReadFunc)(const char*, int32*);
|
||||
prefResult = ((IntPrefReadFunc)inFunc)(GetValidPrefName(), &intValue);
|
||||
value = intValue;
|
||||
}
|
||||
else
|
||||
prefResult = inFunc(GetValidPrefName(), &value);
|
||||
if (prefResult == PREF_NOERROR)
|
||||
SetPaneValue(value ^ (mOrdinal & kOrdinalXORBit));
|
||||
} // MPreference<LControl,XP_Bool>::InitializeUsing
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,XP_Bool>::ReadSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mOrdinal & kOrdinalIntBit) // this bit indicates it's an int conversion
|
||||
InitializeUsing((PrefReadFunc)PREF_GetIntPref);
|
||||
else
|
||||
InitializeUsing(PREF_GetBoolPref);
|
||||
mInitialControlValue = GetPaneValue();
|
||||
} // MPreference<LControl,XP_Bool>::ReadSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,XP_Bool>::ReadDefaultSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!IsLocked())
|
||||
if (mOrdinal & kOrdinalIntBit) // this bit indicates it's an int conversion
|
||||
InitializeUsing((PrefReadFunc)PREF_GetDefaultIntPref);
|
||||
else
|
||||
InitializeUsing(PREF_GetDefaultBoolPref);
|
||||
} // MPreference<LControl,XP_Bool>::ReadDefaultSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,XP_Bool>::WriteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (ShouldWrite())
|
||||
{
|
||||
if (mOrdinal & kOrdinalIntBit) // this bit indicates it's an int conversion
|
||||
PREF_SetIntPref(GetPrefName(), GetPrefValue());
|
||||
else
|
||||
PREF_SetBoolPref(GetPrefName(), GetPrefValue());
|
||||
}
|
||||
} // MPreference<LControl,XP_Bool>::WriteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
XP_Bool MPreference<LControl,XP_Bool>::GetPrefValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// xor the boolean value with the low-order bit of the ordinal
|
||||
return (XP_Bool)(mPaneSelf->GetValue() ^ (mOrdinal & kOrdinalXORBit));
|
||||
} // MPreference<LControl,XP_Bool>::GetPrefValue
|
||||
|
||||
template class MPreference<LControl,XP_Bool>;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// Why the heck would we want a prefcontrol that is just a caption? Only for the use of the
|
||||
// resource template to supply an extra string which initially holds the pref name.
|
||||
// CSpecialFolderCaption is derived from this.
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
XP_Bool MPreference<LGACaption,XP_Bool>::GetPaneValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return false;
|
||||
} // MPreference<LGACaption,XP_Bool>::GetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGACaption,XP_Bool>::SetPaneValue(XP_Bool)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // MPreference<LGACaption,XP_Bool>::SetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreference<LGACaption, XP_Bool>::Changed() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return false;
|
||||
} // MPreference<LGACaption,XP_Bool>::Changed
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGACaption,XP_Bool>::InitializeUsing(PrefReadFunc)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // MPreference<LGACaption,XP_Bool>::InitializeUsing
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGACaption,XP_Bool>::ReadSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
InitializeUsing(PREF_GetBoolPref);
|
||||
mInitialControlValue = false;
|
||||
} // MPreference<LGACaption,XP_Bool>::ReadSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGACaption,XP_Bool>::ReadDefaultSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing(PREF_GetDefaultBoolPref);
|
||||
} // MPreference<LGACaption,XP_Bool>::ReadDefaultSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGACaption,XP_Bool>::WriteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // MPreference<LGACaption,XP_Bool>::WriteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
XP_Bool MPreference<LGACaption,XP_Bool>::GetPrefValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return false;
|
||||
} // MPreference<LGACaption,XP_Bool>::GetPrefValue
|
||||
|
||||
template class MPreference<LGACaption,XP_Bool>;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int32 MPreference<LControl,int32>::GetPaneValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return ((LControl*)mPaneSelf)->GetValue();
|
||||
} // MPreference<LControl,int32>::GetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,int32>::SetPaneValue(int32 inData)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
((LControl*)mPaneSelf)->SetValue(inData);
|
||||
} // MPreference<LControl,int32>::SetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreference<LControl, int32>::Changed() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return GetPaneValue() != mInitialControlValue;
|
||||
} // MPreference<LControl,int32>::Changed
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,int32>::InitializeUsing(PrefReadFunc inFunc)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
int32 value;
|
||||
int prefResult = inFunc(GetValidPrefName(), &value);
|
||||
if (prefResult == PREF_NOERROR)
|
||||
{
|
||||
if (value == mOrdinal)
|
||||
SetPaneValue(1); // tab group will turn others off.
|
||||
}
|
||||
} // MPreference<LControl,int32>::InitializeUsing
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,int32>::ReadSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
InitializeUsing(PREF_GetIntPref);
|
||||
mInitialControlValue = GetPaneValue();
|
||||
} // MPreference<LControl,int32>::ReadSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,int32>::ReadDefaultSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing(PREF_GetDefaultIntPref);
|
||||
} // MPreference<LControl,int32>::ReadDefaultSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LControl,int32>::WriteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (ShouldWrite())
|
||||
PREF_SetIntPref(GetPrefName(), mOrdinal);
|
||||
} // MPreference<int>::WriteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int32 MPreference<LControl,int32>::GetPrefValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mOrdinal;
|
||||
} // MPreference<int>::GetPrefValue
|
||||
|
||||
template class MPreference<LControl,int32>;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
#pragma mark
|
||||
MPreference<LTextEditView,char*>::~MPreference()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
XP_FREEIF(mInitialControlValue);
|
||||
} // MPreference<LTextEditView,char*>::CleanUpData
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* MPreference<LTextEditView,char*>::GetPaneValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CStr255 value;
|
||||
mPaneSelf->GetDescriptor(value);
|
||||
return (char*)value;
|
||||
} // MPreference<LTextEditView,char*>::GetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,char*>::SetPaneValue(char* inData)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
((LTextEditView*)mPaneSelf)->SetDescriptor(CStr255(inData));
|
||||
} // MPreference<LTextEditView,char*>:SetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreference<LTextEditView,char*>::Changed() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char* value = GetPaneValue();
|
||||
if (value && *value)
|
||||
return (strcmp(value, mInitialControlValue) != 0);
|
||||
return true;
|
||||
} // MPreference<LTextEditView,char*>::Changed
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,char*>::InitializeUsing(PrefReadFunc inFunc)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char* value;
|
||||
int prefResult = inFunc(GetValidPrefName(), &value);
|
||||
if (prefResult == PREF_NOERROR)
|
||||
{
|
||||
SetPaneValue(value);
|
||||
XP_FREEIF(value);
|
||||
}
|
||||
} // MPreference<LTextEditView,char*>::InitializeUsing
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,char*>::ReadSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
InitializeUsing(PREF_CopyCharPref);
|
||||
mInitialControlValue = XP_STRDUP(GetPaneValue());
|
||||
} // MPreference<LTextEditView,char*>::ReadSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,char*>::ReadDefaultSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing(PREF_CopyDefaultCharPref);
|
||||
} // MPreference<LTextEditView,char*>::ReadDefaultSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,char*>::WriteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (ShouldWrite())
|
||||
PREF_SetCharPref(GetPrefName(), GetPaneValue());
|
||||
} // MPreference<LTextEditView,char*>::WriteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* MPreference<LTextEditView,char*>::GetPrefValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return GetPaneValue();
|
||||
} // MPreference<LTextEditView,char*>::GetPrefValue
|
||||
|
||||
template class MPreference<LTextEditView,char*>;
|
||||
|
||||
// This is used for captions, and for mixing in with another pref control (eg, to
|
||||
// control the descriptor of a checkbox).
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
#pragma mark
|
||||
MPreference<LPane,char*>::~MPreference()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
XP_FREEIF(mInitialControlValue);
|
||||
} // MPreference<LPane,char*>::CleanUpData
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* MPreference<LPane,char*>::GetPaneValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CStr255 value;
|
||||
mPaneSelf->GetDescriptor(value);
|
||||
return (char*)value;
|
||||
} // MPreference<LPane,char*>::GetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LPane,char*>::SetPaneValue(char* inData)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
((LPane*)mPaneSelf)->SetDescriptor(CStr255(inData));
|
||||
} // MPreference<LPane,char*>:SetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreference<LPane,char*>::Changed() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char* value = GetPaneValue();
|
||||
if (value && *value)
|
||||
return (strcmp(value, mInitialControlValue) != 0);
|
||||
return true;
|
||||
} // MPreference<LPane,char*>::Changed
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LPane,char*>::InitializeUsing(PrefReadFunc inFunc)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char* value;
|
||||
int prefResult = inFunc(GetValidPrefName(), &value);
|
||||
if (prefResult == PREF_NOERROR)
|
||||
{
|
||||
SetPaneValue(value);
|
||||
XP_FREEIF(value);
|
||||
}
|
||||
} // MPreference<LPane,char*>::InitializeUsing
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LPane,char*>::ReadSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
InitializeUsing(PREF_CopyCharPref);
|
||||
mInitialControlValue = XP_STRDUP(GetPaneValue());
|
||||
} // MPreference<LPane,char*>::ReadSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LPane,char*>::ReadDefaultSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing(PREF_CopyDefaultCharPref);
|
||||
} // MPreference<LPane,char*>::ReadDefaultSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LPane,char*>::WriteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // MPreference<LPane,char*>::WriteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* MPreference<LPane,char*>::GetPrefValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return GetPaneValue();
|
||||
} // MPreference<LPane,char*>::GetPrefValue
|
||||
|
||||
template class MPreference<LPane,char*>;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
#pragma mark
|
||||
MPreference<LGAPopup,char*>::~MPreference()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
XP_FREEIF(mInitialControlValue);
|
||||
} // MPreference<LGAPopup,char*>::CleanUpData
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* MPreference<LGAPopup,char*>::GetPaneValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
Int32 itemNumber = ((LGAPopup*)mPaneSelf)->GetValue();
|
||||
CStr255 itemString;
|
||||
if (itemNumber > 0)
|
||||
{
|
||||
MenuHandle menuH = ((LGAPopup*)mPaneSelf)->GetMacMenuH();
|
||||
::GetMenuItemText(menuH, itemNumber, itemString);
|
||||
}
|
||||
return (char*)itemString;
|
||||
} // MPreference<LGAPopup,char*>::GetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGAPopup,char*>::SetPaneValue(char* inData)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inData || !*inData)
|
||||
return;
|
||||
MenuHandle menuH = ((LGAPopup*)mPaneSelf)->GetMacMenuH();
|
||||
short menuSize = ::CountMItems(menuH);
|
||||
CStr255 itemString;
|
||||
for (short menuItem = 1; menuItem <= menuSize; ++menuItem)
|
||||
{
|
||||
::GetMenuItemText(menuH, menuItem, itemString);
|
||||
if (itemString == inData)
|
||||
{
|
||||
StSetBroadcasting dontBroadcast((LGAPopup*)mPaneSelf, false);
|
||||
((LGAPopup*)mPaneSelf)->SetValue(menuItem);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // MPreference<LGAPopup,char*>:SetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreference<LGAPopup,char*>::Changed() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char* value = GetPaneValue();
|
||||
if (value && *value)
|
||||
return (strcmp(value, mInitialControlValue) != 0);
|
||||
return true;
|
||||
} // MPreference<LGAPopup,char*>::Changed
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGAPopup,char*>::InitializeUsing(PrefReadFunc inFunc)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char* value;
|
||||
int prefResult = inFunc(GetValidPrefName(), &value);
|
||||
if (prefResult == PREF_NOERROR)
|
||||
{
|
||||
SetPaneValue(value);
|
||||
XP_FREEIF(value);
|
||||
}
|
||||
} // MPreference<LGAPopup,char*>::InitializeUsing
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGAPopup,char*>::ReadSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
InitializeUsing(PREF_CopyCharPref);
|
||||
mInitialControlValue = XP_STRDUP(GetPaneValue());
|
||||
} // MPreference<LGAPopup,char*>::ReadSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGAPopup,char*>::ReadDefaultSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing(PREF_CopyDefaultCharPref);
|
||||
} // MPreference<LGAPopup,char*>::ReadDefaultSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LGAPopup,char*>::WriteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (ShouldWrite())
|
||||
PREF_SetCharPref(GetPrefName(), GetPaneValue());
|
||||
} // MPreference<LGAPopup,char*>::WriteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* MPreference<LGAPopup,char*>::GetPrefValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return GetPaneValue();
|
||||
} // MPreference<LGAPopup,char*>::GetPrefValue
|
||||
|
||||
template class MPreference<LGAPopup,char*>;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
MPreference<LTextEditView,int32>::~MPreference()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // MPreference<LTextEditView,int32>::CleanUpData
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int32 MPreference<LTextEditView,int32>::GetPaneValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return ((LTextEditView*)mPaneSelf)->GetValue();
|
||||
} // MPreference<LTextEditView,int32>::GetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,int32>::SetPaneValue(int32 inData)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
((LTextEditView*)mPaneSelf)->SetValue(inData);
|
||||
} // MPreference<LTextEditView,int32>:SetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreference<LTextEditView,int32>::Changed() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return GetPaneValue() != mInitialControlValue;
|
||||
} // MPreference<LTextEditView,int32>::Changed
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,int32>::InitializeUsing(PrefReadFunc inFunc)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
int32 value;
|
||||
int prefResult = inFunc(GetValidPrefName(), &value);
|
||||
if (prefResult == PREF_NOERROR)
|
||||
SetPaneValue(value);
|
||||
} // MPreference<LTextEditView,int32>::InitializeUsing
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,int32>::ReadSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
InitializeUsing(PREF_GetIntPref);
|
||||
mInitialControlValue = GetPaneValue();
|
||||
} // MPreference<LTextEditView,int32>::ReadSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,int32>::ReadDefaultSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing(PREF_GetDefaultIntPref);
|
||||
} // MPreference<LTextEditView,int32>::ReadDefaultSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<LTextEditView,int32>::WriteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (ShouldWrite())
|
||||
PREF_SetIntPref(GetPrefName(), GetPaneValue());
|
||||
} // MPreference<LTextEditView,int32>::WriteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int32 MPreference<LTextEditView,int32>::GetPrefValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return GetPaneValue();
|
||||
} // MPreference<LTextEditView,int32>::GetPrefValue
|
||||
|
||||
template class MPreference<LTextEditView,int32>;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// The function signature for reading colors is not like the other types. Here is
|
||||
// its prototype, which we use to cast back and forth.
|
||||
typedef int (*ColorReadFunc)(const char*, uint8*, uint8*, uint8*);
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
MPreference<CColorButton,RGBColor>::~MPreference()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // MPreference<CColorButton,RGBColor>::CleanUpData
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
RGBColor MPreference<CColorButton,RGBColor>::GetPaneValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return ((CColorButton*)mPaneSelf)->GetColor();
|
||||
} // MPreference<CColorButton,RGBColor>::GetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<CColorButton,RGBColor>::SetPaneValue(RGBColor inData)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
((CColorButton*)mPaneSelf)->SetColor(inData);
|
||||
mPaneSelf->Refresh();
|
||||
} // MPreference<CColorButton,RGBColor>:SetPaneValue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
Boolean MPreference<CColorButton,RGBColor>::Changed() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return memcmp(&GetPaneValue(), &mInitialControlValue, sizeof(RGBColor)) == 0;
|
||||
} // MPreference<CColorButton,RGBColor>::Changed
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<CColorButton,RGBColor>::InitializeUsing(PrefReadFunc inFunc)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
RGBColor value;
|
||||
uint8 red = 0, green = 0, blue = 0;
|
||||
int prefResult = ((ColorReadFunc)inFunc)(GetValidPrefName(), &red, &green, &blue);
|
||||
if (prefResult == PREF_NOERROR)
|
||||
{
|
||||
value.red = red << 8;
|
||||
value.green = green << 8;
|
||||
value.blue = blue << 8;
|
||||
SetPaneValue(value);
|
||||
}
|
||||
} // MPreference<CColorButton,RGBColor>::InitializeUsing
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<CColorButton,RGBColor>::ReadSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
InitializeUsing((PrefReadFunc)PREF_GetColorPref);
|
||||
mInitialControlValue = GetPaneValue();
|
||||
} // MPreference<CColorButton,RGBColor>::ReadSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<CColorButton,RGBColor>::ReadDefaultSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing((PrefReadFunc)PREF_GetDefaultColorPref);
|
||||
} // MPreference<CColorButton,RGBColor>::ReadDefaultSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MPreference<CColorButton,RGBColor>::WriteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (ShouldWrite())
|
||||
{
|
||||
RGBColor value = GetPaneValue();
|
||||
PREF_SetColorPref(GetPrefName(), value.red >> 8, value.green >> 8, value.blue >> 8);
|
||||
}
|
||||
} // MPreference<CColorButton,RGBColor>::WriteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
RGBColor MPreference<CColorButton,RGBColor>::GetPrefValue() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return GetPaneValue();
|
||||
} // MPreference<CColorButton,RGBColor>::GetPrefValue
|
||||
|
||||
template class MPreference<CColorButton,RGBColor>;
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class LControl;
|
||||
class LStream;
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// MPreferenceBase is the base class for all the prefs controls and edit fields
|
||||
// in the prefs dialog, and properties dialogs. It allows preference panels to be
|
||||
// easily extended with additional pref controls with just Constructor changes,
|
||||
// as the controls know which pref they represent, and initialize themselves and
|
||||
// write themselves out to the prefs accordingly.
|
||||
//
|
||||
// There are two additional mechanisms that are used in sub-dialogs of the preferences
|
||||
// dialog, to permit the following:
|
||||
//
|
||||
// 1. Sub-dialogs can control the pref for a given server (e.g. IMAP server).
|
||||
//
|
||||
// This is achivieved by a ParamText-type mechanism. Controls in these sub-dialogs
|
||||
// contain pref strings like: "mail.imap.server.^0.username". These controls
|
||||
// construct the real prefs string ("mail.imap.server.nsmail-1.username") on the
|
||||
// fly when reading and writing prefs, e.g. in MPreferenceBase::GetPrefName().
|
||||
//
|
||||
// The stack-based class StReplacementString() allows you to set this replacement
|
||||
// string temporarily, e.g. while showing properties for a mail server.
|
||||
//
|
||||
// 2. Sub-dialogs can write their preferences out to a temporary sub-tree of the
|
||||
// main preferences, the values in which are then copied over to the real
|
||||
// prefs at some later time (e.g. when the user OKs the main prefs dialog
|
||||
//
|
||||
// This is achived by prepending a prefix to the prefs name that is stored
|
||||
// in the PPob. Controls then attempt to read their values first from the
|
||||
// prefs cache (with the prefix), then from the main prefs (without the prefix)
|
||||
// [see GetValidPrefName()]. They then write their values to the temporary prefs
|
||||
// cache if the prefix is in force when the dialog is destroyed.
|
||||
//
|
||||
// The stack-based class StUseTempPrefCache enables this functionality; typically
|
||||
// you'd create one in scope around a call to conduct the sub-dialog , since
|
||||
// the prefix string needs to be in place both when the controls are constructed
|
||||
// and destroyed.
|
||||
//
|
||||
// To copy these cached preference values over to the main prefs tree, call
|
||||
// CopyCachedPrefsToMainPrefs(), say when the user OKs the main prefs dialog.
|
||||
//
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
//======================================
|
||||
class MPreferenceBase
|
||||
//======================================
|
||||
{
|
||||
protected:
|
||||
|
||||
MPreferenceBase(
|
||||
LPane* inPane,
|
||||
LStream* inStream);
|
||||
virtual ~MPreferenceBase();
|
||||
|
||||
public:
|
||||
Boolean IsLocked() const { return mLocked; }
|
||||
virtual void ReadDefaultSelf() = 0; // Reset factory default
|
||||
virtual Boolean Changed() const = 0;
|
||||
virtual void SetPrefName(const char* inNewName, Boolean inReread = true);
|
||||
virtual const char* GetPrefName();
|
||||
virtual const char* GetValidPrefName();
|
||||
virtual const char* GetUnsubstitutedPrefName();
|
||||
virtual void SetWritePref(Boolean inWritePref) { mWritePref = inWritePref; }
|
||||
virtual Boolean GetWritePref() const { return mWritePref; }
|
||||
|
||||
static void ChangePrefName(LView* inSuperView, PaneIDT inPaneID, const char* inNewName);
|
||||
static const char* GetPanePrefName(LView* inSuperView, PaneIDT inPaneID);
|
||||
static const char* GetPaneUnsubstitutedPrefName(LView* inSuperView, PaneIDT inPaneID);
|
||||
|
||||
static void SetWriteOnDestroy(Boolean inWrite) { sWriteOnDestroy = inWrite; }
|
||||
static Boolean GetWriteOnDestroy() { return sWriteOnDestroy; }
|
||||
|
||||
static void SetPaneWritePref(LView* inSuperView, PaneIDT inPaneID, Boolean inWritePref);
|
||||
|
||||
static void InitTempPrefCache();
|
||||
static void SetUseTempPrefCache(Boolean inUseTempPrefPrefix) { sUseTempPrefPrefix = inUseTempPrefPrefix ; }
|
||||
static Boolean GetUseTempPrefCache() { return sUseTempPrefPrefix; }
|
||||
|
||||
static void CopyCachedPrefsToMainPrefs();
|
||||
static void SetReplacementString(const char* s);
|
||||
|
||||
struct StReplacementString // temporarily set and then clear the static string
|
||||
{
|
||||
StReplacementString(const char* s)
|
||||
{
|
||||
MPreferenceBase::SetReplacementString(s);
|
||||
}
|
||||
~StReplacementString()
|
||||
{
|
||||
MPreferenceBase::SetReplacementString(nil);
|
||||
}
|
||||
};
|
||||
|
||||
struct StUseTempPrefCache // temporarily set and then restore the static flag
|
||||
{
|
||||
StUseTempPrefCache(Boolean inTempValue)
|
||||
: mSavedValue(MPreferenceBase::sUseTempPrefPrefix)
|
||||
{
|
||||
MPreferenceBase::sUseTempPrefPrefix = inTempValue;
|
||||
}
|
||||
~StUseTempPrefCache()
|
||||
{
|
||||
MPreferenceBase::sUseTempPrefPrefix = mSavedValue;
|
||||
}
|
||||
Boolean mSavedValue;
|
||||
};
|
||||
|
||||
struct StWriteOnDestroy // temporarily set and then restore the static flag
|
||||
{
|
||||
StWriteOnDestroy(Boolean inTempValue)
|
||||
: mSavedValue(MPreferenceBase::sWriteOnDestroy)
|
||||
{
|
||||
MPreferenceBase::sWriteOnDestroy = inTempValue;
|
||||
}
|
||||
~StWriteOnDestroy()
|
||||
{
|
||||
MPreferenceBase::sWriteOnDestroy = mSavedValue;
|
||||
}
|
||||
Boolean mSavedValue;
|
||||
};
|
||||
|
||||
protected:
|
||||
void FinishCreate();
|
||||
virtual void ReadSelf() = 0; // Call this from FinishCreateSelf!
|
||||
Boolean ShouldWrite() const;
|
||||
void ReadLockState();
|
||||
// data:
|
||||
protected:
|
||||
// From the resource stream:
|
||||
Int16 mOrdinal;
|
||||
// For a boolean pref, this is xored with the value after read and before write.
|
||||
// For an int pref, this represents the value to be saved if the control is on.
|
||||
// From the prefs db
|
||||
Boolean mLocked;
|
||||
Boolean mWritePref; // set to false to tell the control not to write out the pref
|
||||
LPane* mPaneSelf; // Control/edit field that we're mixed in with.
|
||||
|
||||
const char* mSubstitutedName; // name after substitution. Freed on destroy.
|
||||
private:
|
||||
const char* mName; // the prefs name format string
|
||||
|
||||
// Implementation
|
||||
private:
|
||||
friend class CDebugPrefToolTipAttachment;
|
||||
friend class StReplacementString;
|
||||
friend class StWriteOnDestroy;
|
||||
friend class StUseTempPrefCache;
|
||||
static Boolean sWriteOnDestroy; // one for all instantiations of the template.
|
||||
static Boolean sUseTempPrefPrefix; // one for all instantiations of the template.
|
||||
static char* sReplacementString; // for pref name magic names with ^0 in them.
|
||||
// This must only be manipulated using the StReplacementString class.
|
||||
}; // class MPreferenceBase
|
||||
|
||||
|
||||
//======================================
|
||||
template <class TPane,class TData> class MPreference
|
||||
// This is a mixin class that gets added to the pref control types.
|
||||
//======================================
|
||||
: public MPreferenceBase
|
||||
{
|
||||
public:
|
||||
MPreference(
|
||||
LPane* inControl,
|
||||
LStream* inStream);
|
||||
virtual ~MPreference();
|
||||
public:
|
||||
virtual void ReadSelf(); // Call this from FinishCreateSelf!
|
||||
virtual void ReadDefaultSelf();
|
||||
virtual void WriteSelf();
|
||||
virtual TData GetPrefValue() const;
|
||||
virtual TData GetPaneValue() const;
|
||||
virtual void SetPaneValue(TData);
|
||||
virtual Boolean Changed() const;
|
||||
protected:
|
||||
typedef int (*PrefReadFunc)(const char*, TData*);
|
||||
virtual Boolean ShouldWrite() const { return MPreferenceBase::ShouldWrite(); }
|
||||
virtual void ReadLockState() { MPreferenceBase::ReadLockState(); }
|
||||
virtual void InitializeUsing(PrefReadFunc inFunc); // used by ReadSelf, ReadDefaultSelf.
|
||||
// data:
|
||||
protected:
|
||||
// From the constructor:
|
||||
TData mInitialControlValue;
|
||||
}; // template <class TPane, class TData> class MPreference
|
||||
|
||||
@@ -1,636 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "PrefControls.h"
|
||||
|
||||
#include "MPreference.h"
|
||||
#include "CValidEditField.h"
|
||||
|
||||
#include "prefwutil.h"
|
||||
#include "prefapi.h"
|
||||
#include "ufilemgr.h"
|
||||
#include "StSetBroadcasting.h"
|
||||
|
||||
#include "xp_mcom.h"
|
||||
|
||||
#include <LGACheckbox.h>
|
||||
#include <LGARadioButton.h>
|
||||
#include <LGAPopup.h>
|
||||
#include <LGACaption.h>
|
||||
|
||||
// Note. We can do java-style 'inline' virtual functions here, because these classes
|
||||
// all have file scope. If you ever move these declarations to a header, you
|
||||
// should non-inline 'em.
|
||||
|
||||
#pragma mark ---CPrefCheckbox---
|
||||
//======================================
|
||||
class CPrefCheckbox
|
||||
//======================================
|
||||
: public LGACheckbox
|
||||
, public MPreference<LControl,XP_Bool>
|
||||
{
|
||||
public:
|
||||
CPrefCheckbox(LStream* inStream)
|
||||
: LGACheckbox(inStream)
|
||||
, MPreference<LControl,XP_Bool>(this, inStream)
|
||||
{
|
||||
}
|
||||
virtual ~CPrefCheckbox()
|
||||
{
|
||||
WriteSelf();
|
||||
// checkbox always writes its pane value ^ its ordinal.
|
||||
// Thus: if mOrdinal == 1, the checkbox reverses the sense of the pref.
|
||||
}
|
||||
enum { class_ID = 'Pchk' };
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
LGACheckbox::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
}
|
||||
}; // class CPrefCheckbox
|
||||
|
||||
#pragma mark ---CBoolPrefRadio---
|
||||
//======================================
|
||||
class CBoolPrefRadio
|
||||
// Actually, because of the writing-out policy, only the zero-ordinal radio button
|
||||
// needs to be a CBoolPrefRadio. The other one can be just a LGARadioButton.
|
||||
//======================================
|
||||
: public LGARadioButton
|
||||
, public MPreference<LControl,XP_Bool>
|
||||
{
|
||||
public:
|
||||
CBoolPrefRadio(LStream* inStream)
|
||||
: LGARadioButton(inStream)
|
||||
, MPreference<LControl,XP_Bool>(this, inStream)
|
||||
{
|
||||
}
|
||||
virtual ~CBoolPrefRadio()
|
||||
{
|
||||
// Only the radio button with a zero ordinal writes its value out.
|
||||
// It writes out its pane value.
|
||||
if (mOrdinal == 0)
|
||||
WriteSelf();
|
||||
}
|
||||
enum { class_ID = 'Brad' };
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
LGARadioButton::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
}
|
||||
}; // class CBoolPrefRadio
|
||||
|
||||
#pragma mark ---CIntPrefRadio---
|
||||
//======================================
|
||||
class CIntPrefRadio
|
||||
//======================================
|
||||
: public LGARadioButton
|
||||
, public MPreference<LControl,int32>
|
||||
{
|
||||
public:
|
||||
CIntPrefRadio(LStream* inStream)
|
||||
: LGARadioButton(inStream)
|
||||
, MPreference<LControl,int32>(this, inStream)
|
||||
{
|
||||
}
|
||||
virtual ~CIntPrefRadio()
|
||||
{
|
||||
// Only the radio button with an ON value writes its value out.
|
||||
// An int preference writes out its ordinal.
|
||||
if (mPaneSelf->GetValue() != 0)
|
||||
WriteSelf();
|
||||
}
|
||||
enum { class_ID = 'Irad' };
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
LGARadioButton::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
}
|
||||
}; // class CIntPrefRadio
|
||||
|
||||
#pragma mark ---CPrefColorButton---
|
||||
//======================================
|
||||
class CPrefColorButton
|
||||
//======================================
|
||||
: public CColorButton
|
||||
, public MPreference<CColorButton,RGBColor>
|
||||
{
|
||||
public:
|
||||
enum { class_ID = 'Pcol' };
|
||||
CPrefColorButton(LStream* inStream)
|
||||
: CColorButton(inStream)
|
||||
, MPreference<CColorButton,RGBColor>((CColorButton*)this, inStream)
|
||||
{
|
||||
}
|
||||
virtual ~CPrefColorButton()
|
||||
{
|
||||
WriteSelf();
|
||||
}
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
CColorButton::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
}
|
||||
}; // class CPrefColorButton
|
||||
|
||||
#pragma mark ---CIntPrefPopup---
|
||||
//======================================
|
||||
class CIntPrefPopup
|
||||
// NOTE: There are two modes of operation: command mode and item mode.
|
||||
// Command mode happens if mNumCommands > 0, otherwise item mode obtains.
|
||||
// In item mode, unlike the base class LGAPopup, the values are zero based. I.e., the
|
||||
// first menu item represents a pref value of zero.
|
||||
// In command mode, the command numbers of the items are used for the pref values,
|
||||
// allowing the menu items to represent non-consecutive pref values, or reordered
|
||||
// pref values.
|
||||
//======================================
|
||||
: public LGAPopup
|
||||
, public MPreference<LControl,int32>
|
||||
{
|
||||
public:
|
||||
CIntPrefPopup(LStream* inStream)
|
||||
: LGAPopup(inStream)
|
||||
, MPreference<LControl,int32>(this, inStream)
|
||||
{
|
||||
}
|
||||
virtual ~CIntPrefPopup()
|
||||
{
|
||||
WriteSelf();
|
||||
}
|
||||
enum { class_ID = 'Ppop' };
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
LGAPopup::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
}
|
||||
virtual int32 GetPaneValue() const
|
||||
{
|
||||
Int32 itemNumber = LGAPopup::GetValue();
|
||||
// Use the command nums, if provided.
|
||||
if (mNumCommands > 0)
|
||||
return (*mCommandNums)[itemNumber - 1];
|
||||
// Otherwise, use the menu item number - 1 (it's zero based).
|
||||
return itemNumber - 1;
|
||||
}
|
||||
virtual void SetPaneValue(int32 inData)
|
||||
{
|
||||
if (mNumCommands == 0)
|
||||
{
|
||||
// Item mode.
|
||||
LGAPopup::SetValue(inData + 1); // first item's value is zero.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Command mode.
|
||||
CommandT* cur = *mCommandNums;
|
||||
for (int item = 1; item <= mNumCommands; item++, cur++)
|
||||
{
|
||||
if (*cur == inData)
|
||||
{
|
||||
SetValue(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual int32 GetPrefValue() const
|
||||
{
|
||||
return GetPaneValue();
|
||||
}
|
||||
virtual void InitializeUsing(PrefReadFunc inFunc)
|
||||
{
|
||||
int32 value;
|
||||
int prefResult = inFunc(GetValidPrefName(), &value);
|
||||
if (prefResult == PREF_NOERROR)
|
||||
SetPaneValue(value);
|
||||
}
|
||||
virtual void ReadSelf()
|
||||
{
|
||||
InitializeUsing(PREF_GetIntPref);
|
||||
}
|
||||
virtual void ReadDefaultSelf()
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing(PREF_GetDefaultIntPref);
|
||||
}
|
||||
virtual void WriteSelf()
|
||||
{
|
||||
if (ShouldWrite())
|
||||
PREF_SetIntPref(GetPrefName(), GetPaneValue());
|
||||
}
|
||||
|
||||
}; // class CIntPrefPopup
|
||||
|
||||
#pragma mark ---CTextPrefPopup---
|
||||
//======================================
|
||||
class CTextPrefPopup
|
||||
//======================================
|
||||
: public LGAPopup
|
||||
, public MPreference<LGAPopup,char*>
|
||||
{
|
||||
public:
|
||||
CTextPrefPopup(LStream* inStream)
|
||||
: LGAPopup(inStream)
|
||||
, MPreference<LGAPopup,char*>(this, inStream)
|
||||
{
|
||||
}
|
||||
virtual ~CTextPrefPopup()
|
||||
{
|
||||
WriteSelf();
|
||||
}
|
||||
enum { class_ID = 'Tpop' };
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
LGAPopup::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
}
|
||||
}; // class CTextPrefPopup
|
||||
|
||||
#pragma mark ---CPrefEditText---
|
||||
//======================================
|
||||
class CPrefTextEdit
|
||||
//======================================
|
||||
: public CValidEditField
|
||||
, public MPreference<LTextEditView,char*>
|
||||
{
|
||||
public:
|
||||
CPrefTextEdit(LStream* inStream)
|
||||
: CValidEditField(inStream)
|
||||
, MPreference<LTextEditView,char*>((LTextEditView*)this, inStream)
|
||||
{
|
||||
}
|
||||
virtual ~CPrefTextEdit()
|
||||
{
|
||||
// A textedit field always writes its value out.
|
||||
WriteSelf();
|
||||
}
|
||||
enum { class_ID = 'Pedt' };
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
CValidEditField::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
// The edit field with mOrdinal == 1 should become target:
|
||||
if (mOrdinal == 1)
|
||||
((CValidEditField*)mPaneSelf)->GetSuperCommander()->SetLatentSub(this);
|
||||
}
|
||||
}; // class CPrefTextEdit
|
||||
|
||||
#pragma mark ---CIntPrefTextEdit---
|
||||
//======================================
|
||||
class CIntPrefTextEdit
|
||||
// // Note: use CPrefTextEdit template in constructor, just change the class ID to 'Iedt'.
|
||||
//======================================
|
||||
: public CValidEditField
|
||||
, public MPreference<LTextEditView,int32>
|
||||
{
|
||||
public:
|
||||
enum { class_ID = 'Iedt' };
|
||||
CIntPrefTextEdit(LStream* inStream)
|
||||
: CValidEditField(inStream)
|
||||
, MPreference<LTextEditView,int32>((LTextEditView*)this, inStream)
|
||||
{
|
||||
}
|
||||
virtual ~CIntPrefTextEdit()
|
||||
{
|
||||
// A textedit field always writes its value out.
|
||||
WriteSelf();
|
||||
}
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
CValidEditField::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
// The edit field with mOrdinal == 1 should become target:
|
||||
if (mOrdinal == 1)
|
||||
((CValidEditField*)mPaneSelf)->GetSuperCommander()->SetLatentSub(this);
|
||||
}
|
||||
}; // class CIntPrefTextEdit
|
||||
|
||||
#pragma mark ---CPrefFilePicker---
|
||||
//======================================
|
||||
class CPrefFilePicker
|
||||
// mOrdinal determines the PickEnum.
|
||||
//======================================
|
||||
: public CFilePicker
|
||||
, public MPreferenceBase // binary data
|
||||
{
|
||||
public:
|
||||
enum { class_ID = 'Pfpk' };
|
||||
typedef int (*PrefReadFunc)(const char*, void**, int*);
|
||||
CPrefFilePicker(LStream* inStream)
|
||||
: CFilePicker(inStream)
|
||||
, MPreferenceBase((CFilePicker*)this, inStream)
|
||||
{
|
||||
CFilePicker::SetPickType((PickEnum)mOrdinal);
|
||||
}
|
||||
virtual ~CPrefFilePicker()
|
||||
{
|
||||
if (ShouldWrite())
|
||||
{
|
||||
if (CFilePicker::WasSet())
|
||||
{
|
||||
FSSpec fileSpec = CFilePicker::GetFSSpec();
|
||||
AliasHandle a = NULL;
|
||||
OSErr iErr = NewAlias(nil, &fileSpec, &a);
|
||||
if (!iErr)
|
||||
{
|
||||
Size iByteCnt = GetHandleSize((Handle)a);
|
||||
HLock((Handle)a);
|
||||
PREF_SetBinaryPref(GetPrefName(), *a, iByteCnt);
|
||||
DisposeHandle((Handle)a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual Boolean Changed() const
|
||||
{
|
||||
return CFilePicker::WasSet();
|
||||
}
|
||||
virtual void FinishCreateSelf()
|
||||
{
|
||||
CFilePicker::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
}
|
||||
virtual void InitializeUsing(PrefReadFunc inFunc)
|
||||
{
|
||||
// Read old alias pref from resource
|
||||
// XP prefs: Read alias as binary type
|
||||
AliasHandle alias = nil;
|
||||
int size;
|
||||
void* a;
|
||||
if (inFunc(GetValidPrefName(), &a, &size ) == 0)
|
||||
{
|
||||
PtrToHand(a, &(Handle)alias, size);
|
||||
XP_FREE(a);
|
||||
}
|
||||
if (alias && *alias)
|
||||
{
|
||||
FSSpec fileSpec;
|
||||
fileSpec.vRefNum = fileSpec.parID = -1;
|
||||
fileSpec.name[0] = '\0';
|
||||
|
||||
Boolean ignore;
|
||||
OSErr err = ::ResolveAlias(NULL, alias, &fileSpec, &ignore);
|
||||
if (err != noErr)
|
||||
fileSpec.vRefNum = fileSpec.parID = -1;
|
||||
if (CFileMgr::FileExists(fileSpec))
|
||||
{
|
||||
StSetBroadcasting dontBroadcast((CFilePicker*)this, false);
|
||||
CFilePicker::SetFSSpec(fileSpec);
|
||||
}
|
||||
}
|
||||
if (alias)
|
||||
DisposeHandle((Handle)alias);
|
||||
}
|
||||
virtual void ReadSelf()
|
||||
{
|
||||
InitializeUsing(PREF_CopyBinaryPref);
|
||||
}
|
||||
virtual void ReadDefaultSelf()
|
||||
{
|
||||
if (!IsLocked())
|
||||
InitializeUsing(PREF_CopyDefaultBinaryPref);
|
||||
}
|
||||
}; // class CPrefFilePicker
|
||||
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
#include "macutil.h"
|
||||
#include "UNewFolderDialog.h"
|
||||
#include "CMessageFolder.h"
|
||||
|
||||
#pragma mark ---MSpecialFolderMixin---
|
||||
//======================================
|
||||
class MSpecialFolderMixin
|
||||
// Like a pref checkbox, but the descriptor is derived from a second, text preference.
|
||||
// The second pref name is obtained from the main (boolean) one by replacing the substring
|
||||
// "use" by the substring "default", eg
|
||||
// mail.use_fcc -> mail.default_fcc
|
||||
// This conversion allows us to share the constructor resource template. This guy can just have
|
||||
// a different class ID.
|
||||
//======================================
|
||||
{
|
||||
public:
|
||||
MSpecialFolderMixin(LPane* inPane, const char* inPrefName);
|
||||
virtual ~MSpecialFolderMixin();
|
||||
void FinishCreateSelf();
|
||||
void SetTitleUsing(const CStr255& folderName, const CStr255& serverName);
|
||||
const char* GetCaptionPrefName() const
|
||||
{
|
||||
return mCaptionPrefName;
|
||||
}
|
||||
void SetCaptionPrefName(const char* inCaptionPrefName)
|
||||
{
|
||||
XP_FREEIF(mCaptionPrefName);
|
||||
mCaptionPrefName = XP_STRDUP(inCaptionPrefName);
|
||||
}
|
||||
|
||||
protected:
|
||||
LPane* mPane;
|
||||
char* mCaptionPrefName;
|
||||
char* mFormatString;
|
||||
}; // class MSpecialFolderMixin
|
||||
|
||||
//-----------------------------------
|
||||
MSpecialFolderMixin::MSpecialFolderMixin(LPane* inPane, const char* inPrefName)
|
||||
//-----------------------------------
|
||||
: mPane(inPane)
|
||||
, mCaptionPrefName(nil)
|
||||
, mFormatString(nil)
|
||||
{
|
||||
LStr255 originalName = inPrefName;
|
||||
UInt8 position = originalName.Find(".use_", 1);
|
||||
originalName.Replace(position, strlen(".use_"), ".default_", strlen(".default_"));
|
||||
SetCaptionPrefName((const char*)CStr255(ConstStringPtr(originalName)));
|
||||
// The initial descriptor is the format string.
|
||||
CStr255 text;
|
||||
mPane->GetDescriptor(text);
|
||||
mFormatString = XP_STRDUP((char*)text);
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
MSpecialFolderMixin::~MSpecialFolderMixin()
|
||||
//-----------------------------------
|
||||
{
|
||||
XP_FREEIF(mCaptionPrefName);
|
||||
XP_FREEIF(mFormatString);
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void MSpecialFolderMixin::FinishCreateSelf()
|
||||
//-----------------------------------
|
||||
{
|
||||
CStr255 folderName;
|
||||
CMessageFolder folder, server;
|
||||
UFolderDialogs::GetFolderAndServerNames(
|
||||
mCaptionPrefName,
|
||||
folder,
|
||||
folderName,
|
||||
server);
|
||||
|
||||
SetTitleUsing(folderName, server.GetName());
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void MSpecialFolderMixin::SetTitleUsing(
|
||||
const CStr255& folderName,
|
||||
const CStr255& serverName)
|
||||
//-----------------------------------
|
||||
{
|
||||
CStr255 title(mFormatString);
|
||||
StringParamText(title, folderName, serverName);
|
||||
mPane->SetDescriptor(title);
|
||||
}
|
||||
|
||||
#pragma mark ---CSpecialFolderCheckbox---
|
||||
//======================================
|
||||
class CSpecialFolderCheckbox
|
||||
// Like a pref checkbox, but the descriptor is derived from a second, text preference.
|
||||
// The second pref name is obtained from the main (boolean) one by replacing the substring
|
||||
// "use" by the substring "default", eg
|
||||
// mail.use_fcc -> mail.default_fcc
|
||||
// This conversion allows us to share the constructor resource template. This guy can just have
|
||||
// a different class ID.
|
||||
//======================================
|
||||
: public CPrefCheckbox
|
||||
, public MSpecialFolderMixin
|
||||
{
|
||||
private:
|
||||
typedef CPrefCheckbox Inherited;
|
||||
public:
|
||||
enum { class_ID = 'FLck' };
|
||||
CSpecialFolderCheckbox(LStream* inStream);
|
||||
virtual void FinishCreateSelf();
|
||||
}; // class CSpecialFolderCheckbox
|
||||
|
||||
//-----------------------------------
|
||||
CSpecialFolderCheckbox::CSpecialFolderCheckbox(LStream* inStream)
|
||||
//-----------------------------------
|
||||
: CPrefCheckbox(inStream)
|
||||
, MSpecialFolderMixin((LPane*)this, GetValidPrefName())
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void CSpecialFolderCheckbox::FinishCreateSelf()
|
||||
//-----------------------------------
|
||||
{
|
||||
Inherited::FinishCreateSelf();
|
||||
MSpecialFolderMixin::FinishCreateSelf();
|
||||
}
|
||||
|
||||
#pragma mark ---CSpecialFolderCaption---
|
||||
//======================================
|
||||
class CSpecialFolderCaption
|
||||
// See comments for CSpecialFolderCheckbox. This differs only in that there is no checkbox
|
||||
// there.
|
||||
//======================================
|
||||
: public LGACaption
|
||||
, public MPreference<LGACaption,XP_Bool>
|
||||
, public MSpecialFolderMixin
|
||||
{
|
||||
private:
|
||||
typedef LGACaption Inherited;
|
||||
public:
|
||||
enum { class_ID = 'FLcp' };
|
||||
CSpecialFolderCaption(LStream* inStream);
|
||||
virtual void FinishCreateSelf();
|
||||
}; // class CSpecialFolderCaption
|
||||
|
||||
//-----------------------------------
|
||||
CSpecialFolderCaption::CSpecialFolderCaption(LStream* inStream)
|
||||
//-----------------------------------
|
||||
: LGACaption(inStream)
|
||||
, MPreference<LGACaption, XP_Bool>(this, inStream)
|
||||
, MSpecialFolderMixin((LPane*)this, GetValidPrefName())
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void CSpecialFolderCaption::FinishCreateSelf()
|
||||
//-----------------------------------
|
||||
{
|
||||
Inherited::FinishCreateSelf();
|
||||
MPreferenceBase::FinishCreate();
|
||||
MSpecialFolderMixin::FinishCreateSelf();
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void UPrefControls::NoteSpecialFolderChanged(
|
||||
LPane* inDescriptionPane,
|
||||
int inKind,
|
||||
const CMessageFolder& inFolder)
|
||||
// The control is a checkbox displaying (e.g.) "Sent Mail on FooServer". This routine updates
|
||||
// the title after the choice of folder or server has changed.
|
||||
//-----------------------------------
|
||||
{
|
||||
MSpecialFolderMixin* cb = dynamic_cast<MSpecialFolderMixin*>(inDescriptionPane);
|
||||
if (cb)
|
||||
{
|
||||
CStr255 folderName;
|
||||
CMessageFolder server;
|
||||
UFolderDialogs::GetFolderAndServerNames(
|
||||
inFolder,
|
||||
(UFolderDialogs::FolderKind)inKind,
|
||||
folderName,
|
||||
server);
|
||||
cb->SetTitleUsing(folderName, server.GetName());
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void UPrefControls::NoteSpecialFolderChanged(
|
||||
LPane* inDescriptionPane,
|
||||
const char* inNewCaptionPrefName)
|
||||
// The control is a checkbox displaying (e.g.) "Sent Mail on FooServer". This routine updates
|
||||
// the title after the choice of folder or server has changed.
|
||||
//-----------------------------------
|
||||
{
|
||||
MSpecialFolderMixin* cb = dynamic_cast<MSpecialFolderMixin*>(inDescriptionPane);
|
||||
if (cb && XP_STRCMP(cb->GetCaptionPrefName(), inNewCaptionPrefName) != 0)
|
||||
{
|
||||
cb->SetCaptionPrefName(inNewCaptionPrefName);
|
||||
CStr255 folderName;
|
||||
CMessageFolder folder, server;
|
||||
UFolderDialogs::GetFolderAndServerNames(
|
||||
inNewCaptionPrefName,
|
||||
folder,
|
||||
folderName,
|
||||
server);
|
||||
|
||||
cb->SetTitleUsing(folderName, server.GetName());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MOZ_MAIL_NEWS
|
||||
|
||||
//-----------------------------------
|
||||
void UPrefControls::RegisterPrefControlViews()
|
||||
//-----------------------------------
|
||||
{
|
||||
RegisterClass_(CPrefCheckbox);
|
||||
RegisterClass_(CIntPrefRadio);
|
||||
RegisterClass_(CBoolPrefRadio);
|
||||
RegisterClass_(CPrefTextEdit);
|
||||
RegisterClass_(CIntPrefTextEdit);
|
||||
RegisterClass_(CIntPrefPopup);
|
||||
RegisterClass_(CTextPrefPopup);
|
||||
RegisterClass_(CPrefFilePicker);
|
||||
RegisterClass_(CPrefColorButton);
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
RegisterClass_(CSpecialFolderCheckbox);
|
||||
RegisterClass_(CSpecialFolderCaption);
|
||||
#endif // MOZ_MAIL_NEWS
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
class CMessageFolder;
|
||||
#endif // MOZ_MAIL_NEWS
|
||||
|
||||
//======================================
|
||||
class UPrefControls
|
||||
// The control classes themselves are all private. That's the point. They know what
|
||||
// they're doing.
|
||||
|
||||
// So far, the family includes
|
||||
// CPrefTextEdit, CPrefCheckbox, CIntPrefRadio, and CBoolPrefRadio. Each of these
|
||||
// has a custom constructor template.
|
||||
//
|
||||
// These can be added to any window (not just the preferences dialog). You add the
|
||||
// control to your window in constructor, put in the pref name (eg
|
||||
// "browser.foo.bar.mumble") and a number called "mOrdinal".
|
||||
//
|
||||
// In most cases, no code will be required. The control initializes itself by querying
|
||||
// the pref value during FinishCreate(), and updates the associated preference when
|
||||
// destroyed. The latter behavior is determined by a static function call that you
|
||||
// should make if the user hits a "cancel" button.
|
||||
//
|
||||
// The meaning of mOrdinal varies with the type of pane. For a checkbox, mOrdinal
|
||||
// is xored with the value when converting between the pref and the control value,
|
||||
// allowing a checkbox to be worded in the same or the opposite sense to the pref's
|
||||
// semantic. For a boolean radio button group, the one with mOrdinal == 0 corresponds
|
||||
// to the pref value and updates its corresponding pref, while the other one must have
|
||||
// mOrdinal == 1. For an int radio button group, the one whose ordinal matches the
|
||||
// value of the pref gets turned on initially and on destruction, only the one that's
|
||||
// on updates its corresponding pref to the value of its mOrdinal field.
|
||||
//
|
||||
// Future directions might include a popup menu control associated with an int
|
||||
// value, an RGAColor pref control, etc. Well, the future is here. It's done.
|
||||
//======================================
|
||||
{
|
||||
public:
|
||||
static void RegisterPrefControlViews();
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
static void NoteSpecialFolderChanged(
|
||||
LPane* inDescriptionPane,
|
||||
int inKind, /* actually UFolderDialogs::FolderKind */
|
||||
const CMessageFolder& inFolder);
|
||||
static void NoteSpecialFolderChanged(
|
||||
LPane* inDescriptionPane,
|
||||
const char* inNewCaptionPrefName);
|
||||
#endif // MOZ_MAIL_NEWS
|
||||
};
|
||||
@@ -1,273 +0,0 @@
|
||||
// ============================================================================
|
||||
// ¥¥¥ QAP_Assist.h
|
||||
// ============================================================================
|
||||
// QA Partner/Macintosh Driver Assistance Hook Header
|
||||
//
|
||||
// Copyright © 1993-1997 Segue Software, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// QA PARTNER RELEASE VERSION 4.0 BETA 1
|
||||
// THIS IS A BETA RELEASE. THIS SOFTWARE MAY HAVE BUGS. THIS SOFTWARE MAY CHANGE BEFORE FINAL RELEASE.
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _MAC //¥NETSCAPE: added these lines
|
||||
#define _MAC
|
||||
#include <LTableView.h>
|
||||
#endif
|
||||
|
||||
#ifndef __QAP_ASSIST_H__
|
||||
#define __QAP_ASSIST_H__
|
||||
|
||||
#include <LTableView.h>
|
||||
|
||||
|
||||
//¥NETSCAPE: added this definition
|
||||
#define QAP_BUILD
|
||||
|
||||
// The internal name of the QA Partner 4.0 driver
|
||||
#define QAP_DRIVER_NAME "\p.QAP40"
|
||||
|
||||
// The PBControl code to send the driver to set the assist hook
|
||||
#define QAP_SET_ASSIST_HOOK 200
|
||||
|
||||
// The return value you can use if you're not ready to assist the driver
|
||||
#define QAP_CALL_ME_BACK -1
|
||||
|
||||
// Special "index" values for kQAPGetListContents
|
||||
#define QAP_INDEX_ALL -1
|
||||
#define QAP_INDEX_SELECTED -2
|
||||
|
||||
// Prototype for the assist hook function which you must supply
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
pascal short QAP_AssistHook (short selector, long handle, void *buffer, short val, long l_appA5);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef pascal short (*QAPAssistHookPtr)(short, long, void *, short, long);
|
||||
|
||||
// Mixed-Mode junk for QAP_AssistHook
|
||||
#if GENERATINGPOWERPC || defined(powerc) || defined(__powerc) || defined (_MPPC_)
|
||||
enum
|
||||
{
|
||||
uppQAPAssistHookInfo = kPascalStackBased
|
||||
| RESULT_SIZE(SIZE_CODE(sizeof(short)))
|
||||
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
|
||||
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
|
||||
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void *)))
|
||||
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
|
||||
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
|
||||
};
|
||||
|
||||
typedef UniversalProcPtr QAPAssistHookUPP;
|
||||
#define CallQAPAssistHook(userRoutine, selector, handle, buffer, val, appA5) \
|
||||
CallUniversalProc((UniversalProcPtr)(userRoutine), uppQAPAssistHookInfo, (short)(selector), (long)(handle), (void *)(buffer), (short)(val), (long)(appA5))
|
||||
#define NewQAPAssistHook(userRoutine) \
|
||||
(QAPAssistHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppQAPAssistHookInfo, GetCurrentISA())
|
||||
#else
|
||||
typedef QAPAssistHookPtr QAPAssistHookUPP;
|
||||
#define CallQAPAssistHook(userRoutine, selector, handle, buffer, val, appA5) \
|
||||
(*(userRoutine))((short)(selector), (long)(handle), (void *)(buffer), (short)(val), (long)(appA5))
|
||||
#define NewQAPAssistHook(userRoutine) \
|
||||
(QAPAssistHookUPP)(userRoutine)
|
||||
#endif
|
||||
|
||||
// The selectors for the assist hook callback function
|
||||
enum
|
||||
{
|
||||
// selector handle buffer val return
|
||||
// -------- ------ --- --- ------
|
||||
kQAPGetWindowContents, // WindowPtr wcinfo array ptr max array elements number of items returned
|
||||
kQAPGetTextInfo, // from wcinfo textinfo struct ptr 1 0 if no error
|
||||
kQAPGetStaticText, // from wcinfo buffer ptr (Str255) buffer size 0 if no erro
|
||||
kQAPGetListInfo, // from wcinfo listinfo struct ptr 1 0 if no erro
|
||||
kQAPGetListContents, // from wcinfo buffer ptr index 0 if no error
|
||||
kQAPGetCustomItemName, // from wcinfo buffer ptr (Str255) 0 0 if no error
|
||||
kQAPGetCustomItemValue, // from wcinfo buffer ptr (long *) 0
|
||||
kQAPAppToForeground, // NULL NULL 0 0 if no error
|
||||
kQAPAppToBackground, // NULL NULL 0 0 if no error
|
||||
kQAPGetScrollbarInfo,
|
||||
kQAPWin32Service // HWND ptr to paramblock win32 Service Selector
|
||||
};
|
||||
|
||||
// Selectors for win32 services
|
||||
|
||||
enum
|
||||
{
|
||||
kQAP_CB_GetContents,
|
||||
kQAP_CB_GetAttr,
|
||||
kQAP_CB_GetInfo,
|
||||
kQAP_CB_GetItemText,
|
||||
kQAP_CB_GetText,
|
||||
kQAP_CB_IsSelected,
|
||||
kQAP_CB_SelectText,
|
||||
|
||||
kQAP_LB_GetContents,
|
||||
kQAP_LB_GetAtPoint,
|
||||
kQAP_LB_GetAttr,
|
||||
kQAP_LB_GetInfo,
|
||||
kQAP_LB_GetItemInfo,
|
||||
kQAP_LB_GetItemText,
|
||||
kQAP_LB_IsSelected,
|
||||
|
||||
kQAP_LV_GetContents,
|
||||
kQAP_LV_GetAttr,
|
||||
kQAP_LV_GetInfo,
|
||||
kQAP_LV_GetItemInfo,
|
||||
kQAP_LV_GetItemText,
|
||||
kQAP_LV_IsSelected,
|
||||
kQAP_LV_MakeVisible,
|
||||
|
||||
kQAP_PGL_GetContents,
|
||||
kQAP_PGL_GetInfo,
|
||||
kQAP_PGL_GetItemRect,
|
||||
kQAP_PGL_GetItemText,
|
||||
kQAP_PGL_IsSelected,
|
||||
|
||||
kQAP_SCL_GetLayout,
|
||||
kQAP_SCL_GetValues,
|
||||
|
||||
kQAP_TV_GetContents,
|
||||
kQAP_TV_GetAtPoint,
|
||||
kQAP_TV_GetAttr,
|
||||
kQAP_TV_GetInfo,
|
||||
kQAP_TV_GetItemInfo,
|
||||
kQAP_TV_GetItemText,
|
||||
kQAP_TV_IsSelected,
|
||||
|
||||
kQAP_UD_GetLayout,
|
||||
kQAP_UD_GetValues
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// Window type codes for the WCINFO 'type' field
|
||||
WT_COMPLETE = 0, // marker for end of window item list (QAP will not add other items)
|
||||
WT_INCOMPLETE, // marker for end of assist item list (QAP will add other items too)
|
||||
WT_CONTROL, // Apple Control Manager control
|
||||
WT_TEXT_FIELD, // Apple TextEdit Manager Text Field
|
||||
WT_LIST_BOX, // Apple List Manager List Box
|
||||
WT_ASSIST_ITEM, // Custom control (type indicated in 'cls' field)
|
||||
WT_IGNORE, // Internal use
|
||||
|
||||
// Window class codes for the WCINFO 'cls' field (only used for WT_ASSIST_ITEM items)
|
||||
|
||||
WC_STATIC_TEXT = 256,
|
||||
WC_TEXT_FIELD,
|
||||
WC_LIST_BOX,
|
||||
WC_POPUP_LIST,
|
||||
WC_OWNER_DRAW,
|
||||
WC_ICON,
|
||||
WC_PICTURE,
|
||||
WC_CUSTOM,
|
||||
WC_PUSH_BUTTON,
|
||||
WC_CHECK_BOX,
|
||||
WC_RADIO_BUTTON,
|
||||
WC_COMBO_BOX,
|
||||
WC_LIST_VIEW,
|
||||
WC_NULL,
|
||||
WC_PAGE_LIST,
|
||||
WC_TRACK_BAR,
|
||||
WC_TREE_VIEW,
|
||||
WC_UP_DOWN,
|
||||
WC_SCROLL_BAR,
|
||||
WC_WINDOW // Internal use
|
||||
};
|
||||
|
||||
// Values for the 'flags' field of wcinfo
|
||||
#define WCF_DISABLED 0x01
|
||||
#define WCF_NOCONTROL 0x02
|
||||
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED
|
||||
# pragma options align = power
|
||||
#endif
|
||||
|
||||
// The structure to be filled in for each control when the assist hook
|
||||
// is called with the kQAPGetWindowContents selector
|
||||
|
||||
#define MAC_NAME_SIZE 32
|
||||
|
||||
typedef struct wcinfo
|
||||
{
|
||||
Handle handle;
|
||||
Rect rect;
|
||||
short type;
|
||||
short cls;
|
||||
short flags;
|
||||
short pad;
|
||||
char str[MAC_NAME_SIZE];
|
||||
} WCINFO, *PWCINFO, **PPWCINFO;
|
||||
|
||||
// The structure to be filled for the given item when the assist hook
|
||||
// is called with the kQAPGetTextInfo selector
|
||||
|
||||
typedef struct textinfo
|
||||
{
|
||||
Handle handle; // handle to the text if you want me to unlock it
|
||||
TEHandle hTE; // handle to the TE associated with the text (for dialog items)
|
||||
Ptr ptr; // pointer to the actual text (locked if a handle, please)
|
||||
short len; // length of the actual text
|
||||
Boolean hasFocus; // TRUE if typing right now would go to the text field
|
||||
char state; // value for HSetState if <handle> is not NULL
|
||||
char buf[256]; // buffer to copy text into if you need a fixed place
|
||||
} TEXTINFO, *PTEXTINFO, **PPTEXTINFO;
|
||||
|
||||
// The structure to be filled for the given item when the assist hook
|
||||
// is called with the kQAPGetListInfo selector
|
||||
|
||||
typedef struct listinfo
|
||||
{
|
||||
short itemCount; // total number of items in the listbox
|
||||
short topIndex; // 1-based index of top visible item in list
|
||||
short itemHeight; // height of each list item, in pixels
|
||||
short visibleCount; // count of visible list items
|
||||
ControlHandle vScroll; // ListBox's vertical scrollbar, or NULL
|
||||
Boolean isMultiSel; // TRUE if cmd-click selects multiple items
|
||||
Boolean isExtendSel; // TRUE if shift-click extends the selection range
|
||||
Boolean hasText; // TRUE if the list items are textual
|
||||
Boolean reserved;
|
||||
} QAPLISTINFO, *PQAPLISTINFO, **PPQAPLISTINFO;
|
||||
|
||||
typedef struct scrollbarinfo
|
||||
{
|
||||
long lPos;
|
||||
long lMin;
|
||||
long lMax;
|
||||
long lPageSize;
|
||||
long lIncrement;
|
||||
long lVertical;
|
||||
long lHasThumb;
|
||||
Point ptIncrArrow;
|
||||
Point ptDecrArrow;
|
||||
Point ptIncrPage;
|
||||
Point ptDecrPage;
|
||||
Point ptMinThumb;
|
||||
Point ptMaxThumb;
|
||||
} QAPSCROLLBARINFO, *PQAPSCROLLBARINFO, **PPQAPSCROLLBARINFO;
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED
|
||||
# pragma options align = reset
|
||||
#endif
|
||||
|
||||
//¥NETSCAPE --- begin
|
||||
class CQAPartnerTableMixin
|
||||
{
|
||||
public:
|
||||
CQAPartnerTableMixin(LTableView *inView) ;
|
||||
virtual ~CQAPartnerTableMixin() ;
|
||||
|
||||
virtual void QapGetListInfo (PQAPLISTINFO pInfo) = 0;
|
||||
virtual Ptr QapAddCellToBuf(Ptr pBuf, Ptr pLimit, const STableCell& sTblCell) = 0;
|
||||
virtual short QapGetListContents(Ptr pBuf, short index);
|
||||
|
||||
protected:
|
||||
LTableView * mTableView;
|
||||
};
|
||||
//¥NETSCAPE --- end
|
||||
|
||||
#endif // __QAP_ASSIST_H__
|
||||
@@ -1,818 +0,0 @@
|
||||
// ============================================================================
|
||||
// ¥¥¥ QAP_AssistPP.cp
|
||||
// ============================================================================
|
||||
// QA Partner/Macintosh Driver Assistance Hook for
|
||||
// PowerPlant Class Library applications
|
||||
//
|
||||
// Copyright © 1993-1997 Segue Software, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// QA PARTNER RELEASE VERSION 4.0 BETA 1
|
||||
// THIS IS A BETA RELEASE. THIS SOFTWARE MAY HAVE BUGS. THIS SOFTWARE MAY CHANGE BEFORE FINAL RELEASE.
|
||||
|
||||
/*
|
||||
|
||||
To use this assistance hook with your PowerPlant application, do the following:
|
||||
|
||||
1. #include "QAP_Assist.h" in the source file(s) in which you do steps 2 and 3 below.
|
||||
|
||||
2. In your main () function, add calls to the QAP_AssistHook before and after your
|
||||
application's "Run" method, as follows
|
||||
|
||||
...
|
||||
QAP_AssistHook (kQAPAppToForeground, 0, NULL, 0, 0);
|
||||
YourApplication->Run();
|
||||
QAP_AssistHook (kQAPAppToBackground, 0, NULL, 0, 0);
|
||||
...
|
||||
|
||||
3. Sub-class LCommander::PutOnDuty and LCommander::TakeOffDuty (if you havn't already),
|
||||
and add the following to them:
|
||||
|
||||
void CYourApplication::PutOnDuty ()
|
||||
{
|
||||
QAP_AssistHook (kQAPAppToForeground, 0, NULL, 0, 0);
|
||||
LCommander::PutOnDuty ();
|
||||
}
|
||||
|
||||
void CYourApplication::TakeOffDuty ()
|
||||
{
|
||||
LCommander::TakeOffDuty ();
|
||||
QAP_AssistHook (kQAPAppToBackground, 0, NULL, 0, 0);
|
||||
}
|
||||
|
||||
4. The assist hook now uses RTTI to resolve class id at runtime. Make sure RTTI
|
||||
is enabled in your compiler preferences. Also, ensure that the LView static
|
||||
class variable LView::sInFocusView and the instance variable LView::mSubPanes
|
||||
are visible by tweaking 'LView.h' to declare them public.
|
||||
|
||||
5. Add QAP_AssistPP.cp to your project and rebuild.
|
||||
|
||||
*/
|
||||
|
||||
#include "QAP_Assist.h"
|
||||
#ifdef QAP_BUILD
|
||||
#include <string.h>
|
||||
|
||||
#include <LButton.h>
|
||||
#include <LCaption.h>
|
||||
#include <LCicnButton.h>
|
||||
#include <LControl.h>
|
||||
#include <LEditField.h>
|
||||
#include <LGroupBox.h>
|
||||
#include <LIconPane.h>
|
||||
#include <LListBox.h>
|
||||
#include <LArrayIterator.h> //¥NETSCAPE: was LListIterator.h
|
||||
#include <LPicture.h>
|
||||
#include <LPlaceHolder.h>
|
||||
#include <LStdControl.h>
|
||||
#include <LTextButton.h>
|
||||
#include <LTextEditView.h>
|
||||
#include <LToggleButton.h>
|
||||
#include <LView.h>
|
||||
#include <LWindow.h>
|
||||
|
||||
#ifndef PARTNER // Segue internal use
|
||||
# include <LGACheckBox.h>
|
||||
# include <LGADisclosureTriangle.h>
|
||||
# include <LGAPopup.h>
|
||||
# include <LGAIconButtonPopup.h>
|
||||
# include <LGAIconButton.h>
|
||||
# include <LGAPushButton.h>
|
||||
# include <LGATextButton.h>
|
||||
# include <LGARadioButton.h>
|
||||
#endif
|
||||
|
||||
#ifdef PARTNER // Segue internal use
|
||||
# include "ZButton.h"
|
||||
#endif
|
||||
|
||||
#include "CButton.h" //¥NETSCAPE: custom classes
|
||||
#include "CPatternButtonPopup.h"
|
||||
|
||||
#ifndef FALSE //¥NETSCAPE: duh?
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
//¥NETSCAPE:
|
||||
// When the driver calls back QAP_AssistHook with the
|
||||
// 'kQAPGetListContents' selector, it sets a wrong
|
||||
// LPane* in 'l_handle'. This enables a workaround:
|
||||
#define QAP_V4_DRIVER_WORKAROUND
|
||||
|
||||
#pragma segment main
|
||||
|
||||
static short SetAssistHook (QAPAssistHookUPP assistHookUPP);
|
||||
static void AddViewItem (LPane * lpanep, PWCINFO wcp, short * sp_count, short s_type, short s_cls, Handle h);
|
||||
static short GetWindowContents (WindowPtr winp, PWCINFO wcp, short s_max);
|
||||
static short GetListInfo (LPane * lpanep, PQAPLISTINFO p_buffer); //¥NETSCAPE: added
|
||||
static short GetListContents (LPane * lpanep, Ptr p_buffer, short s_val); //¥NETSCAPE: added
|
||||
static short LPaneGetContents (LPane * lpanep, PWCINFO wcp, short * sp_count, short s_max);
|
||||
static short LPaneGetTextInfo (LPane * lpanep, PTEXTINFO textInfop);
|
||||
static short LPaneGetCustomItemName (LPane * lpanep, char * cp_buf);
|
||||
static short LPaneGetCustomItemValue (LPane * lpanep, long * l_value);
|
||||
|
||||
// NOTE: assumes that <MacHeaders> is automatically included
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ QAP_AssistHook
|
||||
// ----------------------------------------------------------------------------
|
||||
// QAP_AssistHook is the actual assistance hook callback.
|
||||
//
|
||||
//¥NETSCAPE:
|
||||
// - The kQAPGetListInfo and kQAPGetListContents cases were out-commented.
|
||||
// - A5 was set/restored on each individual case and the GrafPort was not saved at all.
|
||||
// We now do that at the beginning and the end of the function. Saving the GrafPort
|
||||
// is necessary because of LPaneGetContents() => AddViewItem() => LPane::FocusDraw().
|
||||
|
||||
pascal short QAP_AssistHook (short s_selector, long l_handle, void * p_buffer, short s_val, long l_inAppA5)
|
||||
{
|
||||
short s_result;
|
||||
long l_saveA5;
|
||||
GrafPtr savePort;
|
||||
|
||||
// Set my A5 and grafport
|
||||
if (l_inAppA5 != nil)
|
||||
{
|
||||
l_saveA5 = SetA5 (l_inAppA5); // line order...
|
||||
::GetPort(&savePort); // ...does matter
|
||||
}
|
||||
|
||||
/* Dispatch to the appropiate function and return the result. */
|
||||
|
||||
switch (s_selector)
|
||||
{
|
||||
case kQAPAppToForeground:
|
||||
s_result = SetAssistHook (NewQAPAssistHook (QAP_AssistHook));
|
||||
break;
|
||||
|
||||
case kQAPAppToBackground:
|
||||
s_result = SetAssistHook (NULL);
|
||||
break;
|
||||
|
||||
case kQAPGetWindowContents:
|
||||
s_result = GetWindowContents ((WindowPtr) l_handle, (PWCINFO) p_buffer, s_val);
|
||||
break;
|
||||
|
||||
/*
|
||||
case kQAPGetCustomItemName:
|
||||
LPaneGetCustomItemName ((LPane *) l_handle, (char *) p_buffer);
|
||||
break;
|
||||
*/
|
||||
case kQAPGetCustomItemValue:
|
||||
LPaneGetCustomItemValue ((LPane *) l_handle, (long *) p_buffer);
|
||||
break;
|
||||
|
||||
case kQAPGetTextInfo:
|
||||
s_result = LPaneGetTextInfo ((LPane *) l_handle, (PTEXTINFO) p_buffer);
|
||||
break;
|
||||
|
||||
case kQAPGetListInfo:
|
||||
// PowerPlant LListBox uses the Mac Toolbox ListManager, so QAP gets
|
||||
// the information it needs from the ListHandle. If you use custom
|
||||
// ListBoxes, this selector would be called to retrieve information about the ListBox.
|
||||
s_result = GetListInfo ((LPane *) l_handle, (PQAPLISTINFO) p_buffer);
|
||||
break;
|
||||
|
||||
case kQAPGetListContents:
|
||||
// PowerPlant LListBox uses the Mac Toolbox ListManager, so QAP gets
|
||||
// the information it needs from the ListHandle. If you use custom
|
||||
// ListBoxes, this selector would be called to retrieve the contents the ListBox.
|
||||
s_result = GetListContents ((LPane *) l_handle, (Ptr) p_buffer, s_val);
|
||||
break;
|
||||
|
||||
default:
|
||||
s_result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// restore A5 and grafport
|
||||
if (l_inAppA5 != nil)
|
||||
{
|
||||
::SetPort(savePort); // line order...
|
||||
l_saveA5 = SetA5 (l_saveA5); // ...does matter
|
||||
}
|
||||
|
||||
return s_result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ SetAssistHook
|
||||
// ----------------------------------------------------------------------------
|
||||
// SetAssistHook makes the appropriate PBControl call to the QA Partner driver to install
|
||||
// the assistance hook callback
|
||||
|
||||
static short SetAssistHook (QAPAssistHookUPP assistHookUPP)
|
||||
{
|
||||
CntrlParam cp;
|
||||
OSErr osErr;
|
||||
|
||||
if ((osErr = OpenDriver (QAP_DRIVER_NAME, &cp.ioCRefNum)) != 0)
|
||||
return osErr;
|
||||
|
||||
cp.ioNamePtr = NULL;
|
||||
cp.ioVRefNum = 0;
|
||||
cp.csCode = QAP_SET_ASSIST_HOOK;
|
||||
* (QAPAssistHookUPP *) & cp.csParam[0] = assistHookUPP;
|
||||
* (long *) & cp.csParam[2] = (long) SetCurrentA5 ();
|
||||
|
||||
if ((osErr = PBControlSync ((ParmBlkPtr) & cp)) != 0)
|
||||
return osErr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ AddViewItem
|
||||
// ----------------------------------------------------------------------------
|
||||
// AddViewItem adds a given item to the window contents list.
|
||||
|
||||
static void AddViewItem (LPane * lpanep, PWCINFO wcp, short * sp_count, short s_type, short s_cls, char * cp_name, Handle h)
|
||||
{
|
||||
wcp += * sp_count;
|
||||
++ * sp_count;
|
||||
wcp->type = s_type;
|
||||
wcp->cls = s_cls;
|
||||
wcp->handle = h;
|
||||
|
||||
if (cp_name)
|
||||
strncpy (wcp->str, cp_name, MAC_NAME_SIZE-1);
|
||||
|
||||
if (lpanep)
|
||||
{
|
||||
lpanep->FocusDraw ();
|
||||
lpanep->CalcPortFrameRect (wcp->rect);
|
||||
wcp->flags = (lpanep->IsEnabled () ? 0 : WCF_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ GetWindowContents
|
||||
// ----------------------------------------------------------------------------
|
||||
// GetWindowContents is called by the assistance hook to fill in the
|
||||
// window contents structures for all the relevant views in a given window.
|
||||
|
||||
static short GetWindowContents (WindowPtr winp, PWCINFO wcp, short s_max)
|
||||
{
|
||||
LWindow * lwindowp;
|
||||
short s_count = 0;
|
||||
LView * lviewp_saveFocus;
|
||||
|
||||
lviewp_saveFocus = LView::GetInFocusView(); //¥NETSCAPE: was LView::sInFocusView;
|
||||
|
||||
lwindowp = LWindow::FetchWindowObject (winp);
|
||||
|
||||
if (lwindowp != nil)
|
||||
LPaneGetContents (lwindowp, wcp, & s_count, s_max);
|
||||
|
||||
// The following call tells the QAP Agent that the list provided is incomplete.
|
||||
// The Agent will go ahead and perform its usual traversal of toolbox data structures.
|
||||
// If you do not want to perform this search, comment this line out.
|
||||
|
||||
AddViewItem (0, wcp, & s_count, WT_INCOMPLETE, 0, NULL, 0);
|
||||
|
||||
if (lviewp_saveFocus)
|
||||
lviewp_saveFocus->FocusDraw ();
|
||||
|
||||
return s_count;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ GetListInfo //¥NETSCAPE: added
|
||||
// ----------------------------------------------------------------------------
|
||||
static short GetListInfo (LPane * lpanep, PQAPLISTINFO p_buffer)
|
||||
{
|
||||
#ifdef QAP_V4_DRIVER_WORKAROUND
|
||||
lpanep = (LPane *)(((long*)lpanep)[4]);
|
||||
#endif //QAP_V4_DRIVER_WORKAROUND
|
||||
CQAPartnerTableMixin* qaTable = dynamic_cast <CQAPartnerTableMixin*> (lpanep);
|
||||
if (qaTable != NULL)
|
||||
qaTable->QapGetListInfo(p_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ GetListContents //¥NETSCAPE: added
|
||||
// ----------------------------------------------------------------------------
|
||||
static short GetListContents (LPane * lpanep, Ptr p_buffer, short s_val)
|
||||
{
|
||||
#ifdef QAP_V4_DRIVER_WORKAROUND
|
||||
lpanep = (LPane *)(((long*)lpanep)[4]);
|
||||
#endif //QAP_V4_DRIVER_WORKAROUND
|
||||
CQAPartnerTableMixin* qaTable = dynamic_cast <CQAPartnerTableMixin*> (lpanep);
|
||||
if (qaTable != NULL)
|
||||
return (qaTable->QapGetListContents(p_buffer, s_val));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ LPaneGetContents
|
||||
// ----------------------------------------------------------------------------
|
||||
// LPaneGetContents is called by GetWindowContents
|
||||
// and recursively by itself to fill in some window contents structures
|
||||
// for a given LPane.
|
||||
|
||||
static short LPaneGetContents (LPane * lpanep, PWCINFO wcp, short * sp_count, short s_max)
|
||||
{
|
||||
LView * lviewp;
|
||||
LEditField * leditFieldp;
|
||||
LListBox * llistBoxp;
|
||||
LStdControl * lstdControlp;
|
||||
LTextEditView * LTextEditViewp;
|
||||
PaneIDT id;
|
||||
Str255 str;
|
||||
char str_name[MAC_NAME_SIZE];
|
||||
|
||||
if (* sp_count == s_max)
|
||||
return 0;
|
||||
|
||||
if ((llistBoxp = dynamic_cast <LListBox*> (lpanep)) != NULL)
|
||||
{
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_LIST_BOX, 0, NULL, (Handle) llistBoxp->GetMacListH ());
|
||||
// Adjust bounding rect to exclude the scrollbars.
|
||||
Rect r_adjusted = wcp [*sp_count-1].rect;
|
||||
if ((** llistBoxp->GetMacListH ()).vScroll != NULL)
|
||||
r_adjusted.right -= 15;
|
||||
if ((** llistBoxp->GetMacListH ()).hScroll != NULL)
|
||||
r_adjusted.bottom -= 15;
|
||||
wcp [*sp_count-1].rect = r_adjusted;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((lstdControlp = dynamic_cast <LStdControl*> (lpanep)) != NULL)
|
||||
{
|
||||
((LCaption *) lpanep)->GetDescriptor (str);
|
||||
p2cstr (str);
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_CONTROL, 0, (char *) str, (Handle) lstdControlp->GetMacControl ());
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((leditFieldp = dynamic_cast <LEditField*> (lpanep)) != NULL)
|
||||
{
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_TEXT_FIELD, 0, NULL, (Handle) leditFieldp->GetMacTEH ());
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((LTextEditViewp = dynamic_cast <LTextEditView*> (lpanep)) != NULL)
|
||||
{
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_TEXT_FIELD, 0, NULL, (Handle) LTextEditViewp->GetMacTEH ());
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LGroupBox*> (lpanep) != NULL)
|
||||
{
|
||||
((LGroupBox *) lpanep)->GetDescriptor (str);
|
||||
p2cstr (str);
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_STATIC_TEXT, (char *) str, (Handle) lpanep);
|
||||
// Change bounding rect to textbox frame. To do this, you need to change the access modifier of
|
||||
// LGroupBox::CalcTextBoxFrame() from protected to public.
|
||||
// ((LGroupBox *) lpanep)->CalcTextBoxFrame (wcp [*sp_count-1].rect);
|
||||
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LCaption*> (lpanep) != NULL)
|
||||
{
|
||||
((LCaption *) lpanep)->GetDescriptor (str);
|
||||
p2cstr (str);
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_STATIC_TEXT, (char *) str, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
#ifdef PARTNER
|
||||
if (dynamic_cast <ZButton*> (lpanep) != NULL)
|
||||
{
|
||||
// For in-house use, call the ZButton method
|
||||
((ZButton *) lpanep)->GetCDescriptor (str_name);
|
||||
if (strcmp (str_name, "") == 0)
|
||||
{
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
}
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, str_name, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
#endif
|
||||
if ((dynamic_cast <LButton*> (lpanep) != NULL) ||
|
||||
(dynamic_cast <LCicnButton*> (lpanep) != NULL))
|
||||
{
|
||||
// Return the pane id as control name
|
||||
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
// Modify or override this to return window class WC_PUSH_BUTTON,
|
||||
// WC_CHECK_BOX or WC_RADIO_BUTTON as appropriate for your use of LButton.
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, str_name, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LTextButton*> (lpanep) != NULL)
|
||||
{
|
||||
((LCaption *) lpanep)->GetDescriptor (str);
|
||||
p2cstr (str);
|
||||
// According to doc, LTextButton's default behaviour is that of a radio button.
|
||||
// If this is not your case, change window class below as appropriate.
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_RADIO_BUTTON, (char *) str, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LToggleButton*> (lpanep) != NULL)
|
||||
{
|
||||
// Return the pane id as control name
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
// LToggleButton is essentially a fancy check box.
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CHECK_BOX, str_name, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LIconPane*> (lpanep) != NULL)
|
||||
{
|
||||
// Return the pane id as control name
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_ICON, str_name, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LPlaceHolder*> (lpanep) != NULL)
|
||||
{
|
||||
// Return the pane id as control name
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CUSTOM, str_name, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
#ifndef PARTNER
|
||||
if (dynamic_cast <LGACheckbox *> (lpanep) != NULL)
|
||||
{
|
||||
((LGACheckbox *) lpanep)->GetDescriptor (str);
|
||||
p2cstr (str);
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CHECK_BOX, (char *) str, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LGADisclosureTriangle *> (lpanep) != NULL)
|
||||
{
|
||||
// Return the pane id as control name
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CHECK_BOX, str_name /*¥NETSCAPE: was NULL*/, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LGAPopup *> (lpanep) != NULL)
|
||||
{
|
||||
((LGAPopup *) lpanep)->GetDescriptor (str);
|
||||
p2cstr (str);
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_POPUP_LIST, (char *) str, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LGAIconButtonPopup *> (lpanep) != NULL)
|
||||
{
|
||||
// Return the pane id as control name
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_POPUP_LIST, str_name /*¥NETSCAPE: was NULL*/, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LGAIconButton *> (lpanep) != NULL)
|
||||
{
|
||||
// Return the pane id as control name
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
|
||||
switch (((LGAIconButton *) lpanep)->GetControlMode ())
|
||||
{
|
||||
case controlMode_Button:
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, (char *) str_name /*¥NETSCAPE: was str*/, (Handle) lpanep);
|
||||
break;
|
||||
case controlMode_RadioButton:
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_RADIO_BUTTON, (char *) str_name /*¥NETSCAPE: was str*/, (Handle) lpanep);
|
||||
break;
|
||||
case controlMode_Switch:
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CHECK_BOX, (char *) str_name /*¥NETSCAPE: was str*/, (Handle) lpanep);
|
||||
break;
|
||||
}
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((dynamic_cast <LGAPushButton *> (lpanep) != NULL) ||
|
||||
(dynamic_cast <LGATextButton *> (lpanep) != NULL))
|
||||
{
|
||||
((LGAPopup *) lpanep)->GetDescriptor (str);
|
||||
p2cstr (str);
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, (char *) str, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <LGARadioButton *> (lpanep) != NULL)
|
||||
{
|
||||
((LGAPopup *) lpanep)->GetDescriptor (str);
|
||||
p2cstr (str);
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_RADIO_BUTTON, (char *) str, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dynamic_cast <LPicture*> (lpanep) != NULL)
|
||||
{
|
||||
// Return the pane id as control name
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PICTURE, str_name, (Handle) lpanep);
|
||||
// LPicture is subclassed from LView, and can have subViews. Don't exit.
|
||||
}
|
||||
|
||||
//¥ NETSCAPE --- begin
|
||||
if (dynamic_cast <CPatternButtonPopup *> (lpanep) != NULL)
|
||||
{
|
||||
// Return the pane id as control name
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_POPUP_LIST, str_name, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <CButton*> (lpanep) != NULL)
|
||||
{
|
||||
((CButton *)lpanep)->GetDescriptor(str);
|
||||
p2cstr(str);
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, (char *) str, (Handle) lpanep);
|
||||
goto Done;
|
||||
|
||||
short s_type = WC_PUSH_BUTTON;
|
||||
if (((CButton *)lpanep)->IsBehaviourRadio())
|
||||
s_type = WC_RADIO_BUTTON;
|
||||
else
|
||||
if (((CButton *)lpanep)->IsBehaviourToggle())
|
||||
s_type = WC_CHECK_BOX;
|
||||
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, s_type, (char *) str, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (dynamic_cast <CQAPartnerTableMixin*> (lpanep) != NULL)
|
||||
{
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_LIST_BOX, (char *) str_name, (Handle) lpanep);
|
||||
goto Done;
|
||||
}
|
||||
//¥ NETSCAPE --- end
|
||||
|
||||
|
||||
//¥ NETSCAPE: below is the generic LView handler - put your custom types above
|
||||
if ((lviewp = dynamic_cast <LView*> (lpanep)) != NULL)
|
||||
{
|
||||
LArrayIterator iterator (lviewp->GetSubPanes (), LArrayIterator::from_Start);
|
||||
LPane * lpanep_sub;
|
||||
|
||||
while (iterator.Next (& lpanep_sub))
|
||||
{
|
||||
if (lpanep_sub->IsVisible ())
|
||||
LPaneGetContents (lpanep_sub, wcp, sp_count, s_max);
|
||||
if (* sp_count == s_max)
|
||||
break;
|
||||
}
|
||||
goto Done;
|
||||
}
|
||||
|
||||
/*
|
||||
The following is a catch-all which will return any other LPane as a CustomWin, including
|
||||
"cosmetic" LPanes with no functionality. If you don't want this to happen,
|
||||
comment the next four lines out.
|
||||
*/
|
||||
/*
|
||||
id = lpanep->GetPaneID ();
|
||||
* (long *) str_name = id;
|
||||
str_name[4] = 0;
|
||||
AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CUSTOM, str_name, (Handle) lpanep);
|
||||
*/
|
||||
Done:
|
||||
return * sp_count;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ LPaneGetTextInfo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static short LPaneGetTextInfo (LPane * lpanep, PTEXTINFO textInfop)
|
||||
{
|
||||
LCaption * lcaptionp;
|
||||
LGroupBox * lgroupBoxp;
|
||||
|
||||
memset (textInfop, 0, sizeof (TEXTINFO));
|
||||
|
||||
if ((lcaptionp = dynamic_cast <LCaption*> (lpanep)) != NULL)
|
||||
{
|
||||
lcaptionp->GetDescriptor ((unsigned char *) textInfop->buf);
|
||||
textInfop->hTE = NULL;
|
||||
textInfop->hasFocus = FALSE;
|
||||
textInfop->len = textInfop->buf[0];
|
||||
textInfop->handle = NULL;
|
||||
textInfop->state = FALSE;
|
||||
textInfop->ptr = (char *) & textInfop->buf[1];
|
||||
}
|
||||
|
||||
if ((lgroupBoxp = dynamic_cast <LGroupBox*> (lpanep)) != NULL)
|
||||
{
|
||||
lgroupBoxp->GetDescriptor ((unsigned char *) textInfop->buf);
|
||||
textInfop->hTE = NULL;
|
||||
textInfop->hasFocus = FALSE;
|
||||
textInfop->len = textInfop->buf[0];
|
||||
textInfop->handle = NULL;
|
||||
textInfop->state = FALSE;
|
||||
textInfop->ptr = (char *) & textInfop->buf[1];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ LPaneGetCustomItemName
|
||||
// ----------------------------------------------------------------------------
|
||||
// If you want the assist hook to return the name of a GUI object, to
|
||||
// be used as the tag, make sure this function returns what you need.xxx
|
||||
// Name must be a NULL terminated c-string, shorter than 256 characters.
|
||||
/*
|
||||
static short LPaneGetCustomItemName (LPane * lpanep, char * cp_buf)
|
||||
{
|
||||
|
||||
* cp_buf = 0;
|
||||
|
||||
// For classes without obvious descriptor, by default we use the 4 character PaneID for tag.
|
||||
// Change this if you want to return a different descriptor.
|
||||
LButton * lbuttonp;
|
||||
LCicnButton * lcicnButtonp;
|
||||
LTextButton * ltextButtonp;
|
||||
LToggleButton * ltoggleButtonp;
|
||||
LPicture * lpicturep;
|
||||
LIconPane * liconPanep;
|
||||
|
||||
PaneIDT id;
|
||||
|
||||
if ((lbuttonp = dynamic_cast <LButton *> (lpanep)) != NULL)
|
||||
{
|
||||
id = lbuttonp->GetPaneID ();
|
||||
* (long *) cp_buf = id;
|
||||
cp_buf[4] = 0;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((lcicnButtonp = dynamic_cast <LCicnButton *> (lpanep)) != NULL)
|
||||
{
|
||||
id = lbuttonp->GetPaneID ();
|
||||
* (long *) cp_buf = id;
|
||||
cp_buf[4] = 0;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((ltextButtonp = dynamic_cast <LTextButton *> (lpanep)) != NULL)
|
||||
{
|
||||
ltextButtonp->GetDescriptor ((unsigned char *) cp_buf);
|
||||
p2cstr ((StringPtr) cp_buf);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((ltoggleButtonp = dynamic_cast <LToggleButton *> (lpanep)) != NULL)
|
||||
{
|
||||
id = ltoggleButtonp->GetPaneID ();
|
||||
* (long *) cp_buf = id;
|
||||
cp_buf[4] = 0;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((lpicturep = dynamic_cast <LPicture *> (lpanep)) != NULL)
|
||||
{
|
||||
id = lpicturep->GetPaneID ();
|
||||
* (long *) cp_buf = id;
|
||||
cp_buf[4] = 0;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((liconPanep = dynamic_cast <LIconPane *> (lpanep)) != NULL)
|
||||
{
|
||||
id = liconPanep->GetPaneID ();
|
||||
* (long *) cp_buf = id;
|
||||
cp_buf[4] = 0;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
|
||||
Done:
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ LPaneGetCustomItemValue
|
||||
// ----------------------------------------------------------------------------
|
||||
static short LPaneGetCustomItemValue (LPane * lpanep, long * l_value)
|
||||
{
|
||||
|
||||
* l_value = 0;
|
||||
|
||||
LControl * lcontrolp;
|
||||
|
||||
if ((lcontrolp = dynamic_cast <LControl *> (lpanep)) != NULL)
|
||||
{
|
||||
* l_value = lcontrolp->GetValue ();
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Done:
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ¥ CQAPartnerTableMixin //¥NETSCAPE: added
|
||||
// ----------------------------------------------------------------------------
|
||||
CQAPartnerTableMixin::CQAPartnerTableMixin(LTableView * inTable)
|
||||
: mTableView(inTable)
|
||||
{
|
||||
}
|
||||
|
||||
CQAPartnerTableMixin::~CQAPartnerTableMixin()
|
||||
{
|
||||
}
|
||||
|
||||
short CQAPartnerTableMixin::QapGetListContents(Ptr pBuf, short index)
|
||||
{
|
||||
STableCell sTblCell;
|
||||
short count = 0;
|
||||
Ptr pLimit;
|
||||
|
||||
if (pBuf == NULL || mTableView == NULL)
|
||||
return 0;
|
||||
|
||||
pLimit = pBuf + *(long *)pBuf;
|
||||
|
||||
TableIndexT outRows, outCols;
|
||||
mTableView->GetTableSize(outRows, outCols);
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case QAP_INDEX_ALL:
|
||||
mTableView->IndexToCell(1, sTblCell);
|
||||
if (mTableView->IsValidCell(sTblCell))
|
||||
{
|
||||
do
|
||||
{
|
||||
if ((pBuf = QapAddCellToBuf(pBuf, pLimit, sTblCell)) != NULL)
|
||||
{
|
||||
count ++;
|
||||
sTblCell.SetCell(sTblCell.row, outCols);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (mTableView->GetNextCell(sTblCell));
|
||||
}
|
||||
break;
|
||||
|
||||
case QAP_INDEX_SELECTED:
|
||||
sTblCell = mTableView->GetFirstSelectedCell();
|
||||
if (mTableView->IsValidCell(sTblCell))
|
||||
{
|
||||
do
|
||||
{
|
||||
if ((pBuf = QapAddCellToBuf(pBuf, pLimit, sTblCell)) != NULL)
|
||||
{
|
||||
count ++;
|
||||
sTblCell.SetCell(sTblCell.row, outCols);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (mTableView->GetNextSelectedCell(sTblCell));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
sTblCell.row = index + 1;
|
||||
sTblCell.col = 1;
|
||||
if (mTableView->IsValidCell(sTblCell))
|
||||
{
|
||||
if ((pBuf = QapAddCellToBuf(pBuf, pLimit, sTblCell)) != NULL)
|
||||
count ++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif // QAP_BUILD
|
||||
@@ -1,104 +0,0 @@
|
||||
//////////////////////////////////
|
||||
|
||||
//
|
||||
// StRegionHandle.h
|
||||
//
|
||||
// by Drew Thaler, athaler@umich.edu
|
||||
// released 9/21/96
|
||||
//
|
||||
// This source code is public domain.
|
||||
//
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
// MGY: renamed to StRegionHandle (from StRegion) to avoid conflict with
|
||||
// existing StRegion.
|
||||
|
||||
#ifndef _StRegionHandle_H_
|
||||
#define _StRegionHandle_H_
|
||||
|
||||
|
||||
#pragma mark -- StRegionHandle --
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ¥ StRegionHandle
|
||||
// -------------------------------------------------------------------------
|
||||
//
|
||||
// This class is an abstraction of the Macintosh Region data structure,
|
||||
// implemented entirely with inline functions. It's meant to provide an
|
||||
// easy-to-use interface to most of the standard region operations -- copying,
|
||||
// adding, subtracting, xor'ing, intersecting, converting to/from rectangles,
|
||||
// etc -- while using the magic of C++ to protect the user from the gory details.
|
||||
//
|
||||
// Benefits: ¥ Automatic memory management -- say goodbye to NewRgn, DisposeRgn, etc!
|
||||
// ¥ Standard operators like +=, -=, &=, ==, etc for both Rects and RgnHandles
|
||||
// ¥ Automatic coercion operators, can use directly in Toolbox calls
|
||||
// ¥ No extra function calls: feels like C++, generates code like C.
|
||||
//
|
||||
|
||||
|
||||
class StRegionHandle
|
||||
{
|
||||
|
||||
public:
|
||||
StRegionHandle() { mRegion = ::NewRgn(); }
|
||||
StRegionHandle(const RgnHandle fromRgn) { mRegion = ::NewRgn(); ::CopyRgn( fromRgn, mRegion ); }
|
||||
StRegionHandle(const Rect &fromRect) { mRegion = ::NewRgn(); ::RectRgn( mRegion, &fromRect ); }
|
||||
~StRegionHandle() { if (mRegion) ::DisposeRgn(mRegion); }
|
||||
|
||||
Rect bbox() const { return (**mRegion).rgnBBox; }
|
||||
void GetBounds(Rect &outRect) const { outRect = (**mRegion).rgnBBox; }
|
||||
void Clear() { ::SetEmptyRgn(mRegion); }
|
||||
Boolean IsEmpty() const { return ::EmptyRgn(mRegion); }
|
||||
RgnHandle Detach() { RgnHandle oldRegion = mRegion; mRegion = ::NewRgn(); return oldRegion; }
|
||||
|
||||
Boolean IsValid() { return (mRegion!=nil); }
|
||||
|
||||
operator RgnHandle() const { return mRegion; }
|
||||
operator Handle() const { return (Handle)mRegion; }
|
||||
|
||||
RgnHandle & operator += ( RgnHandle r ) { ::UnionRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator -= ( RgnHandle r ) { ::DiffRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator |= ( RgnHandle r ) { ::UnionRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator &= ( RgnHandle r ) { ::SectRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator ^= ( RgnHandle r ) { ::XorRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator = ( RgnHandle r ) { ::CopyRgn(r,mRegion); return mRegion; }
|
||||
|
||||
RgnHandle & operator += ( Rect & rect ) { StRegionHandle r(rect); ::UnionRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator -= ( Rect & rect ) { StRegionHandle r(rect); ::DiffRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator |= ( Rect & rect ) { StRegionHandle r(rect); ::UnionRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator &= ( Rect & rect ) { StRegionHandle r(rect); ::SectRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator ^= ( Rect & rect ) { StRegionHandle r(rect); ::XorRgn(mRegion,r,mRegion); return mRegion; }
|
||||
RgnHandle & operator = ( Rect &r ) { ::RectRgn(mRegion,&r); return mRegion; }
|
||||
|
||||
Boolean operator == ( RgnHandle r ) { return ::EqualRgn(r,mRegion); }
|
||||
Boolean operator != ( RgnHandle r ) { return !::EqualRgn(r,mRegion); }
|
||||
|
||||
Boolean operator == ( Rect & rect ) { StRegionHandle r(rect); return ::EqualRgn(r,mRegion); }
|
||||
Boolean operator != ( Rect & rect ) { StRegionHandle r(rect); return !::EqualRgn(r,mRegion); }
|
||||
|
||||
// why not, so you can do "if rgn == 0", right?
|
||||
RgnHandle & operator = ( int x ) { ::SetEmptyRgn(mRegion); return mRegion; }
|
||||
Boolean operator == ( int x ) { return ( (x==0) && ::EmptyRgn(mRegion) ); }
|
||||
Boolean operator != ( int x ) { return ( (x!=0) || !::EmptyRgn(mRegion) ); }
|
||||
|
||||
|
||||
private:
|
||||
RgnHandle mRegion;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
|
||||
#pragma mark -- StTempRegion --
|
||||
|
||||
typedef class StRegionHandle StTempRegion;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _StRegionHandle_H_
|
||||
|
||||
@@ -1,531 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "UDeferredTask.h"
|
||||
|
||||
#include <LCommander.h>
|
||||
#include <LListener.h>
|
||||
|
||||
#include "CWindowMenu.h"
|
||||
#include "CNetscapeWindow.h"
|
||||
#include <typeinfo>
|
||||
|
||||
CDeferredTaskManager* CDeferredTaskManager::sManager = nil;
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTaskManager::CDeferredTaskManager()
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mQueueList(nil)
|
||||
{
|
||||
sManager = this;
|
||||
StartIdling();
|
||||
} // CDeferredTaskManager::CDeferredTaskManager
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTaskManager::~CDeferredTaskManager()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
sManager = nil;
|
||||
} // CDeferredTaskManager::CDeferredTaskManager
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/*static*/ void CDeferredTaskManager::DoQuit(Int32 /*inSaveOption*/)
|
||||
// Called from uapp.cp. Allow any pending tasks to complete before quitting.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Allow all the close tasks to finish. When the last task is done, sManager should
|
||||
// be set to null.
|
||||
EventRecord stupidNullEvent = {0};
|
||||
for (int timeOutCounter = 0; sManager && timeOutCounter < 500; timeOutCounter++)
|
||||
{
|
||||
sManager->DoExecuteTasks(); // netlib might be needed.
|
||||
DevoteTimeToRepeaters(stupidNullEvent);
|
||||
}
|
||||
Assert_(!sManager); // ow! we ran 500 times and the manager is still alive!
|
||||
} // CDeferredTaskManager::DoQuit
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/* static */ void CDeferredTaskManager::Post(CDeferredTask* inTask, LPane* inPane, bool inUnique)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inTask)
|
||||
return;
|
||||
try
|
||||
{
|
||||
// If this is the first post, we'll make a new manager
|
||||
if (!sManager)
|
||||
new CDeferredTaskManager;
|
||||
sManager->DoPost(inTask, inPane, inUnique);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
} // CDeferredTaskManager::Post
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/* static */ void CDeferredTaskManager::Remove(CDeferredTask*& inTask, LPane* inPane)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
Assert_(sManager);
|
||||
if (sManager)
|
||||
sManager->DoRemove(inTask, inPane);
|
||||
// Task may already have executed and been removed. Always zero the caller's stale
|
||||
// pointer.
|
||||
inTask = nil;
|
||||
} // CDeferredTaskManager::Remove
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/* static */ void CDeferredTaskManager::ClearQueue(LPane* inPane)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// If there's no sManager, then there are no queues, so there's nothing to do.
|
||||
if (!sManager)
|
||||
return;
|
||||
sManager->DoClearQueue(inPane);
|
||||
} // CDeferredTaskManager::Remove
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskManager::DoPost(CDeferredTask* inTask, LPane* inPane, Boolean inUnique)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
LWindow* window = nil;
|
||||
if (inPane)
|
||||
window = LWindow::FetchWindowObject(inPane->GetMacPort());
|
||||
|
||||
// Try to find a queue matching this window:
|
||||
CDeferredTaskQueue* q = mQueueList;
|
||||
while (q)
|
||||
{
|
||||
if (q->mQueueWindow == window)
|
||||
break;
|
||||
q = q->mNext;
|
||||
}
|
||||
if (!q)
|
||||
{
|
||||
// no queue for this window yet. Make one, insert it at front of list.
|
||||
try
|
||||
{
|
||||
q = new CDeferredTaskQueue(window);
|
||||
q->mNext = mQueueList;
|
||||
mQueueList = q;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Got a queue. Post the task to it. If it's a unique ("Post1") operation, remove
|
||||
// all tasks of the same type first.
|
||||
if (inUnique)
|
||||
q->DoRemoveType(inTask);
|
||||
q->DoPost(inTask);
|
||||
} // CDeferredTaskManager::DoPost
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskManager::DoRemove(CDeferredTask*& inTask, LPane* inPane)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inTask)
|
||||
return;
|
||||
LWindow* window = nil;
|
||||
if (inPane)
|
||||
window = LWindow::FetchWindowObject(inPane->GetMacPort());
|
||||
if (window)
|
||||
DoRemove(inTask, window);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskManager::DoRemove(CDeferredTask*& inTask, LWindow* inWindow)
|
||||
// A nil window is OK (and represents the global "nil" queue).
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inTask)
|
||||
return;
|
||||
|
||||
// Try to find a queue matching the specified window.
|
||||
// Note to those who follow: the window pointed to by inWindow may be deleted, but
|
||||
// the pointer is still usable as an identifier for the task's queue.
|
||||
CDeferredTaskQueue* q = mQueueList;
|
||||
CDeferredTaskQueue* prev = nil;
|
||||
while (q)
|
||||
{
|
||||
if (q->mQueueWindow == inWindow)
|
||||
{
|
||||
q->DoRemove(inTask);
|
||||
break;
|
||||
}
|
||||
prev = q;
|
||||
q = q->mNext;
|
||||
}
|
||||
|
||||
// If the queue for this window is empty, delete it from the queue list.
|
||||
if (q && q->mFrontTask == nil)
|
||||
RemoveNextQueueAfter(prev);
|
||||
|
||||
// If there are no more queues, die. Life is not worth living if there are no more
|
||||
// queues for me to manage.
|
||||
if (!mQueueList)
|
||||
delete this;
|
||||
} // CDeferredTaskManager::DoRemove
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskManager::RemoveNextQueueAfter(CDeferredTaskQueue* inPreviousQueue)
|
||||
// Remove the queue following the inPreviousQueue. If inPreviousQueue is nil, remove
|
||||
// first queue.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CDeferredTaskQueue* q = inPreviousQueue ? inPreviousQueue->mNext : mQueueList;
|
||||
CDeferredTaskQueue* next = q->mNext;
|
||||
delete q;
|
||||
if (inPreviousQueue)
|
||||
inPreviousQueue->mNext = next;
|
||||
else
|
||||
mQueueList = next;
|
||||
} // CDeferredTaskManager::RemoveNextQueueAfter
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskManager::DoClearQueue(LPane* inPane)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
LWindow* window = nil;
|
||||
if (inPane)
|
||||
window = LWindow::FetchWindowObject(inPane->GetMacPort());
|
||||
if (window)
|
||||
DoClearQueue(window);
|
||||
} // CDeferredTaskManager::DoClearQueue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskManager::DoClearQueue(LWindow* inWindow)
|
||||
// A nil window is OK (and represents the global "nil" queue).
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Try to find a queue matching the specified window.
|
||||
// Note to those who follow: the window pointed to by inWindow may be deleted, but
|
||||
// the pointer is still usable as an identifier for the task's queue.
|
||||
CDeferredTaskQueue* q = mQueueList;
|
||||
CDeferredTaskQueue* prev = nil;
|
||||
while (q)
|
||||
{
|
||||
if (q->mQueueWindow == inWindow)
|
||||
{
|
||||
q->DoClearSelf();
|
||||
break;
|
||||
}
|
||||
prev = q;
|
||||
q = q->mNext;
|
||||
}
|
||||
|
||||
// If the queue for this window is empty, delete it from the queue list.
|
||||
if (q && q->mFrontTask == nil)
|
||||
RemoveNextQueueAfter(prev);
|
||||
|
||||
// If there are no more queues, die. Life is not worth living if there are no more
|
||||
// queues for me to manage.
|
||||
if (!mQueueList)
|
||||
delete this;
|
||||
} // CDeferredTaskManager::DoClearQueue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskManager::DoExecuteTasks()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Try to execute the first task in each window's queue.
|
||||
CDeferredTaskQueue* q = mQueueList;
|
||||
while (q)
|
||||
{
|
||||
CDeferredTask* frontTask = q->mFrontTask;
|
||||
CDeferredTaskQueue* nextQueue = q->mNext;
|
||||
if (frontTask)
|
||||
{
|
||||
CDeferredTask::ExecuteResult result = frontTask->Execute();
|
||||
if (result == CDeferredTask::eDoneDelete)
|
||||
{
|
||||
DoRemove(frontTask, q->mQueueWindow);
|
||||
// Note to those who follow: the window may be deleted here, but
|
||||
// the pointer is still usable as an identifier for the task's queue.
|
||||
}
|
||||
else if (result == CDeferredTask::eWaitStepBack)
|
||||
{
|
||||
// front task didn't complete its work, and wants to yield to the second
|
||||
// task (if any) on the next go round.
|
||||
CDeferredTask* nextTask = frontTask->mNext;
|
||||
if (nextTask)
|
||||
{
|
||||
q->mFrontTask = nextTask;
|
||||
frontTask->mNext = nextTask->mNext;
|
||||
nextTask->mNext = frontTask;
|
||||
}
|
||||
}
|
||||
// The third case (eWaitStayFront) is handled by just passing on to the next
|
||||
// queue.
|
||||
}
|
||||
q = nextQueue;
|
||||
}
|
||||
} // CDeferredTaskManager::ExecuteTasks
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskManager::SpendTime(const EventRecord&)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
DoExecuteTasks();
|
||||
} // CDeferredTaskManager::SpendTime
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTaskQueue::CDeferredTaskQueue(LWindow* inWindow)
|
||||
// A nil window is OK (and represents the global "nil" queue).
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mFrontTask(nil)
|
||||
, mQueueWindow(inWindow)
|
||||
, mNext(nil)
|
||||
{
|
||||
} // CDeferredTaskQueue::CDeferredTaskQueue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTaskQueue::~CDeferredTaskQueue()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // CDeferredTaskQueue::CDeferredTaskQueue
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskQueue::DoPost(CDeferredTask* inTask)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CDeferredTask* cur = mFrontTask;
|
||||
CDeferredTask* prev = nil;
|
||||
while (cur)
|
||||
{
|
||||
prev = cur;
|
||||
cur = cur->mNext;
|
||||
}
|
||||
if (prev)
|
||||
prev->mNext = inTask;
|
||||
else
|
||||
mFrontTask = inTask;
|
||||
} // CDeferredTaskQueue::DoPost
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskQueue::DoRemove(CDeferredTask*& inTask)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inTask)
|
||||
return;
|
||||
CDeferredTask* cur = mFrontTask;
|
||||
CDeferredTask* prev = nil;
|
||||
while (cur)
|
||||
{
|
||||
if (cur == inTask)
|
||||
{
|
||||
// Found the task in the queue, remove it.
|
||||
CDeferredTask* next = inTask->mNext;
|
||||
delete inTask;
|
||||
inTask = nil; // that's why it's a reference.
|
||||
// Note that possibly inTask == mFrontTask
|
||||
if (prev)
|
||||
prev->mNext = next;
|
||||
else
|
||||
mFrontTask = next;
|
||||
break;
|
||||
}
|
||||
prev = cur;
|
||||
cur = cur->mNext;
|
||||
}
|
||||
} // CDeferredTaskQueue::DoRemove
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskQueue::DoRemoveType(CDeferredTask* inTask)
|
||||
// Remove all tasks whose class type is the same as inTask. Used in Post1() calls before
|
||||
// posting the new class.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inTask)
|
||||
return;
|
||||
CDeferredTask* cur = mFrontTask;
|
||||
CDeferredTask* prev = nil;
|
||||
while (cur)
|
||||
{
|
||||
CDeferredTask* next = cur->mNext;
|
||||
if (typeid(*cur) == typeid(*inTask))
|
||||
{
|
||||
// Found a matching task in the queue, remove it.
|
||||
delete cur;
|
||||
if (prev)
|
||||
prev->mNext = next;
|
||||
else
|
||||
mFrontTask = next;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev = cur;
|
||||
}
|
||||
cur = next;
|
||||
}
|
||||
} // CDeferredTaskQueue::DoRemove
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CDeferredTaskQueue::DoClearSelf()
|
||||
// Remove all tasks whose class type is the same as inTask. Used in Post1() calls before
|
||||
// posting the new class.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
while (mFrontTask)
|
||||
{
|
||||
CDeferredTask* dead = mFrontTask;
|
||||
mFrontTask = dead->mNext;
|
||||
delete dead;
|
||||
}
|
||||
} // CDeferredTaskQueue::ClearSelf
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTask::CDeferredTask()
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mNext(nil)
|
||||
, mExecuting(false)
|
||||
#if DEBUG
|
||||
, mExecuteAttemptCount(0)
|
||||
#endif
|
||||
{
|
||||
} // CDeferredTask::CDeferredTask
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTask::~CDeferredTask()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // CDeferredTask::~CDeferredTask
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTask::ExecuteResult CDeferredTask::Execute()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mExecuting)
|
||||
return eWaitStayFront;
|
||||
#if DEBUG
|
||||
mExecuteAttemptCount++;
|
||||
Assert_((mExecuteAttemptCount & 0x000003FF) != 0); // assert every 1024 attempts.
|
||||
#endif
|
||||
mExecuting = true;
|
||||
ExecuteResult result = eWaitStayFront;
|
||||
try
|
||||
{
|
||||
result = ExecuteSelf();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
result = eDoneDelete; // if threw exception, delete task so it won't execute again.
|
||||
}
|
||||
mExecuting = false;
|
||||
return result;
|
||||
} // CDeferredTask::Execute
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredCommand::CDeferredCommand(
|
||||
LCommander* inCommander,
|
||||
CommandT inCommand,
|
||||
void* ioParam)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mCommander(inCommander)
|
||||
, mCommand(inCommand)
|
||||
, mParam(ioParam)
|
||||
{
|
||||
} // CDeferredCommand::CDeferredCommand
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTask::ExecuteResult CDeferredCommand::ExecuteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mCommander && !mCommander->ObeyCommand(mCommand, mParam))
|
||||
return eWaitStayFront;
|
||||
return eDoneDelete;
|
||||
} // CDeferredCommand::ExecuteSelf
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredMessage::CDeferredMessage(
|
||||
LListener* inListener,
|
||||
MessageT inMessage,
|
||||
void* ioParam)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mListener(inListener)
|
||||
, mMessage(inMessage)
|
||||
, mParam(ioParam)
|
||||
{
|
||||
} // CDeferredMessage::CDeferredMessage
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTask::ExecuteResult CDeferredMessage::ExecuteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mListener)
|
||||
mListener->ListenToMessage(mMessage, mParam);
|
||||
return eDoneDelete;
|
||||
} // CDeferredMessage::ExecuteSelf
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredCloseTask::CDeferredCloseTask(
|
||||
LPane* inPane)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mWindow(nil)
|
||||
{
|
||||
if (inPane)
|
||||
mWindow = dynamic_cast<CNetscapeWindow*>
|
||||
(LWindow::FetchWindowObject(inPane->GetMacPort()));
|
||||
if (mWindow)
|
||||
{
|
||||
mWindow->StopAllContexts(); // This can reshow the window, so do it first.
|
||||
mWindow->Hide();
|
||||
// Make sure there are no other load tasks and such.
|
||||
CDeferredTaskManager::ClearQueue(mWindow);
|
||||
}
|
||||
} // CDeferredCloseTask::CDeferredCloseTask
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
CDeferredTask::ExecuteResult CDeferredCloseTask::ExecuteSelf()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mWindow)
|
||||
return eDoneDelete;
|
||||
// Allow the double-click timer in the thread window to time out and delete itself
|
||||
// probably unnecessary to wait - safer?
|
||||
if (mWindow->ClickTimesAreClose(::TickCount()))
|
||||
return eWaitStayFront;
|
||||
// Wait till any pending URLs are finished
|
||||
if (mWindow->IsAnyContextBusy())
|
||||
return eWaitStayFront;
|
||||
if (mWindow)
|
||||
mWindow->DoClose();
|
||||
return eDoneDelete;
|
||||
} // CDeferredCloseTask::ExecuteSelf
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
/* static */ CDeferredCloseTask* CDeferredCloseTask::DeferredClose(LPane* inPane)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CDeferredCloseTask* task = new CDeferredCloseTask(inPane);
|
||||
CDeferredTaskManager::Post(task, inPane);
|
||||
return task;
|
||||
}
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//========================================================================================
|
||||
// This file contains a suite of classes that allow posting and deferred execution
|
||||
// of tasks in any powerplant application (except for CDeferredCloseTask, which is
|
||||
// specific to Communicator).
|
||||
|
||||
// CDeferredTaskManager: A singleton class, manages each per-window queue of tasks,
|
||||
// together with one global "nil" queue. It is created only when
|
||||
// a task is first posted, and is deleted as soon as no more
|
||||
// tasks exist.
|
||||
// CDeferredTaskQueue: A queue of tasks. Each task belongs to a window (except that
|
||||
// one global "nil" queue is allowed), and tasks for
|
||||
// different windows are in different queues. A queue is created
|
||||
// only when needed and is deleted immediately it becomes empty.
|
||||
|
||||
// CDeferredTask: The abstract base class for tasks that can be posted.
|
||||
// CDeferredCommand This is an example of a deferred task object. Its ExecuteSelf()
|
||||
// method calls ObeyCommand
|
||||
// CDeferredMessage This is another example, but calls ListenToMessage instead.
|
||||
// CDeferredCloseTask Another example. Closes a window when it's safe.
|
||||
//========================================================================================
|
||||
|
||||
#include <LPeriodical.h>
|
||||
|
||||
class CDeferredTaskQueue; // forward.
|
||||
class CDeferredTask; // forward.
|
||||
|
||||
//========================================================================================
|
||||
class CDeferredTaskManager
|
||||
// On each idle, the task manager will walk the queue list. For each queue, it will
|
||||
// take the following action:
|
||||
// Tell the first task to execute. If the task returns true, the task is then
|
||||
// deleted. If it returns false, it is left in the queue to be tried on the next idle.
|
||||
// There are only a few public entry points: Post and Remove. Each of these has
|
||||
// an LPane* parameter that is used to work out which window, and hence which queue, the
|
||||
// task belongs to. When posting, a new queue will be opened for the window in question,
|
||||
// if none exists. When removing, the queue is deleted if no more tasks remain in it.
|
||||
//========================================================================================
|
||||
: public LPeriodical
|
||||
{
|
||||
public: // ---------- BEGIN PUBLIC API ------------- //
|
||||
static void Post(CDeferredTask* inTask, LPane* inPane,
|
||||
bool inUnique = false);
|
||||
// Post a task to the end of the queue. If
|
||||
// inUnique is true all others of the same
|
||||
// type will be removed.
|
||||
static void Remove(CDeferredTask*& inTask, LPane* inPane);
|
||||
// Remove task.
|
||||
static void ClearQueue(LPane* inPane);
|
||||
// Remove all tasks from this queue.
|
||||
static void DoQuit(Int32 inSaveOption);
|
||||
// Finish all the close tasks.
|
||||
// ---------- END PUBLIC API ------------- //
|
||||
protected:
|
||||
CDeferredTaskManager();
|
||||
~CDeferredTaskManager();
|
||||
virtual void SpendTime(const EventRecord&);
|
||||
void DoExecuteTasks();
|
||||
void DoPost(
|
||||
CDeferredTask* inTask,
|
||||
LPane* inPane,
|
||||
Boolean inUnique);
|
||||
void DoRemove(
|
||||
CDeferredTask*& inTask,
|
||||
LPane* inPane);
|
||||
void DoRemove(
|
||||
CDeferredTask*& inTask,
|
||||
LWindow* inWindow);
|
||||
void DoClearQueue(LPane* inPane);
|
||||
void DoClearQueue(LWindow* inWindow);
|
||||
void RemoveNextQueueAfter(
|
||||
CDeferredTaskQueue* inPreviousQueue);
|
||||
// data
|
||||
protected:
|
||||
CDeferredTaskQueue* mQueueList;
|
||||
static CDeferredTaskManager* sManager;
|
||||
}; // class CDeferredTaskManager
|
||||
|
||||
//========================================================================================
|
||||
class CDeferredTaskQueue
|
||||
// There is one queue per window, and optionally one global one (with mQueueWindow
|
||||
// == nil). The first task in each queue "blocks" any subsequent tasks in the same queue.
|
||||
// FIFO order is thus guaranteed.
|
||||
//========================================================================================
|
||||
{
|
||||
friend class CDeferredTaskManager;
|
||||
protected:
|
||||
CDeferredTaskQueue(LWindow* inWindow);
|
||||
~CDeferredTaskQueue();
|
||||
void DoPost(CDeferredTask* inTask);
|
||||
void DoRemove(CDeferredTask*& inTask);
|
||||
void DoRemoveType(CDeferredTask* inTask);
|
||||
void DoClearSelf();
|
||||
// data
|
||||
protected:
|
||||
LWindow* mQueueWindow;
|
||||
CDeferredTaskQueue* mNext;
|
||||
CDeferredTask* mFrontTask;
|
||||
}; // class CDeferredWindowTaskQueue
|
||||
|
||||
//========================================================================================
|
||||
class CDeferredTask
|
||||
// Base class for various useful types of deferred tasks. Derived classes must implement
|
||||
// ExecuteSelf(), returning an ExecuteResult value of:
|
||||
// eWaitStayFront task is to be tried again, and wishes to remain blocking the queue
|
||||
// eWaitDoneDelete task has done its work and is to be deleted
|
||||
// eWaitStepBack task is to be tried again, but willing to step back in the queue
|
||||
// to give the next task a chance. (background, low priority)
|
||||
//========================================================================================
|
||||
{
|
||||
protected:
|
||||
enum ExecuteResult { eWaitStayFront, eDoneDelete, eWaitStepBack };
|
||||
CDeferredTask();
|
||||
virtual ~CDeferredTask();
|
||||
virtual ExecuteResult ExecuteSelf() = 0;
|
||||
private:
|
||||
ExecuteResult Execute();
|
||||
// data
|
||||
protected:
|
||||
friend class CDeferredTaskManager;
|
||||
friend class CDeferredTaskQueue;
|
||||
CDeferredTask* mNext;
|
||||
Boolean mExecuting; // reentrancy protection.
|
||||
#if DEBUG
|
||||
UInt32 mExecuteAttemptCount;
|
||||
#endif
|
||||
}; // class CDeferredTask
|
||||
|
||||
class LCommander;
|
||||
|
||||
//========================================================================================
|
||||
class CDeferredCommand
|
||||
// This is an example of a CDeferredTask. This one calls ObeyCommand on a commander.
|
||||
//========================================================================================
|
||||
: public CDeferredTask
|
||||
{
|
||||
public:
|
||||
CDeferredCommand(
|
||||
LCommander* inCommander,
|
||||
CommandT inCommand,
|
||||
void* ioParam);
|
||||
virtual ExecuteResult ExecuteSelf();
|
||||
// data
|
||||
LCommander* mCommander;
|
||||
CommandT mCommand;
|
||||
void* mParam;
|
||||
}; // class CDeferredCommand
|
||||
|
||||
class LListener;
|
||||
|
||||
//========================================================================================
|
||||
class CDeferredMessage
|
||||
// This is an example of a CDeferredTask. This one calls ListenToMessage on a listener.
|
||||
//========================================================================================
|
||||
: public CDeferredTask
|
||||
{
|
||||
public:
|
||||
CDeferredMessage(
|
||||
LListener* inListener,
|
||||
MessageT inMessage,
|
||||
void* ioParam);
|
||||
virtual ExecuteResult ExecuteSelf();
|
||||
// data
|
||||
LListener* mListener;
|
||||
MessageT mMessage;
|
||||
void* mParam;
|
||||
}; // class CDeferredMessage
|
||||
|
||||
class CNetscapeWindow;
|
||||
|
||||
//========================================================================================
|
||||
class CDeferredCloseTask
|
||||
// This guy closes a window at a later, safer time. The parameter to the constructor is
|
||||
// any pane (usually the calling pane), from which the window object is deduced. This
|
||||
// only works for CNetscapeWindows
|
||||
//========================================================================================
|
||||
: public CDeferredTask
|
||||
{
|
||||
public:
|
||||
CDeferredCloseTask(LPane* inPane);
|
||||
static CDeferredCloseTask* DeferredClose(LPane* inPane);
|
||||
protected:
|
||||
virtual ExecuteResult ExecuteSelf();
|
||||
// data
|
||||
protected:
|
||||
CNetscapeWindow* mWindow;
|
||||
}; // class CDeferredCloseTask
|
||||
@@ -1,60 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// ===========================================================================
|
||||
// UFixedFontSwitcher.cp
|
||||
// ===========================================================================
|
||||
//
|
||||
// Authror: Frank Tang ftang@netscape.com
|
||||
|
||||
#include "UFixedFontSwitcher.h"
|
||||
#include "uprefd.h"
|
||||
/*-----------------------------------------------------------------------------
|
||||
UFixedFontSwitcher
|
||||
Class know how to switch font depend on CPrefs:CCharSet
|
||||
It use Singleton (See Design Patterns by Erich Gamma )
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
UFixedFontSwitcher* UFixedFontSwitcher::fTheOnlyInstance = NULL;
|
||||
UFixedFontSwitcher* UFixedFontSwitcher::Instance()
|
||||
{
|
||||
if(fTheOnlyInstance == NULL)
|
||||
fTheOnlyInstance = new UFixedFontSwitcher();
|
||||
return fTheOnlyInstance;
|
||||
}
|
||||
void UFixedFontSwitcher::EncodingTextFont(INTL_Encoding_ID encoding)
|
||||
{
|
||||
switch(encoding)
|
||||
{
|
||||
case CS_DINGBATS:
|
||||
TextFontDingbats();
|
||||
break;
|
||||
case CS_SYMBOL:
|
||||
TextFontSymbol();
|
||||
break;
|
||||
default:
|
||||
{
|
||||
CCharSet charset;
|
||||
Boolean gotFont = CPrefs::GetFont(encoding, &charset);
|
||||
|
||||
Assert_(gotFont);
|
||||
::TextFont(charset.fFixedFontNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// ===========================================================================
|
||||
// UFixedFontSwitcher.h
|
||||
// ===========================================================================
|
||||
//
|
||||
// Authror: Frank Tang ftang@netscape.com
|
||||
|
||||
#pragma once
|
||||
#include "libi18n.h"
|
||||
#include "UFontSwitcher.h"
|
||||
/*-----------------------------------------------------------------------------
|
||||
UFixedFontSwitcher
|
||||
Class know how to switch font depend on CPrefs:CCharSet
|
||||
It use Singleton (See Design Patterns by Erich Gamma )
|
||||
-----------------------------------------------------------------------------*/
|
||||
class UFixedFontSwitcher : public UFontSwitcher{
|
||||
public:
|
||||
UFixedFontSwitcher() {};
|
||||
static UFixedFontSwitcher* Instance();
|
||||
virtual void EncodingTextFont(INTL_Encoding_ID encoding);
|
||||
private:
|
||||
static UFixedFontSwitcher* fTheOnlyInstance;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user