diff --git a/mozilla/xpfc/layout/Makefile b/mozilla/xpfc/layout/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/layout/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/layout/inc/Makefile b/mozilla/xpfc/layout/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/layout/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/layout/inc/manifest.mn b/mozilla/xpfc/layout/inc/manifest.mn new file mode 100644 index 00000000000..92eeb1364fc --- /dev/null +++ b/mozilla/xpfc/layout/inc/manifest.mn @@ -0,0 +1,22 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + nsLayout.h \ + nsBoxLayout.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/layout/inc/nsBoxLayout.h b/mozilla/xpfc/layout/inc/nsBoxLayout.h new file mode 100644 index 00000000000..251eec4b62d --- /dev/null +++ b/mozilla/xpfc/layout/inc/nsBoxLayout.h @@ -0,0 +1,90 @@ +/* -*- 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 nsBoxLayout_h___ +#define nsBoxLayout_h___ + +#include "nsLayout.h" +#include "nsIXPFCCanvas.h" +#include "nsIIterator.h" + + +enum nsLayoutAlignment { + eLayoutAlignment_none, + eLayoutAlignment_horizontal, + eLayoutAlignment_vertical, +}; + + +class nsBoxLayout : public nsLayout +{ +public: + nsBoxLayout(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + NS_IMETHOD Init(nsIXPFCCanvas * aContainer); + + NS_IMETHOD Layout(); + + NS_IMETHOD PreferredSize(nsSize &aSize); + NS_IMETHOD MinimumSize(nsSize &aSize); + NS_IMETHOD MaximumSize(nsSize &aSize); + + NS_IMETHOD_(PRUint32) GetHorizontalGap(); + NS_IMETHOD_(PRUint32) GetVerticalGap(); + NS_IMETHOD_(void) SetHorizontalGap(PRUint32 aGapSize); + NS_IMETHOD_(void) SetVerticalGap(PRUint32 aGapSize); + + NS_IMETHOD_(PRFloat64) GetHorizontalFill(); + NS_IMETHOD_(PRFloat64) GetVerticalFill(); + NS_IMETHOD_(void) SetHorizontalFill(PRFloat64 aFillSize); + NS_IMETHOD_(void) SetVerticalFill(PRFloat64 aFillSize); + +protected: + ~nsBoxLayout(); + +private: + NS_IMETHOD LayoutContainer(); + NS_IMETHOD LayoutChildren(); + NS_IMETHOD CreateIterator(nsIIterator ** aIterator) ; + +private: + nsIXPFCCanvas * mContainer; + nsLayoutAlignment mLayoutAlignment; + PRUint32 mVerticalGap; + PRUint32 mHorizontalGap; + PRFloat64 mVerticalFill; + PRFloat64 mHorizontalFill; + +// XXX This needs to be put into an interface +public: + NS_IMETHOD_(nsLayoutAlignment) GetLayoutAlignment(); + NS_IMETHOD_(void) SetLayoutAlignment(nsLayoutAlignment aLayoutAlignment); + +private: + NS_IMETHOD_(PRBool) CanLayoutUsingPreferredSizes(nsIIterator * aIterator); + NS_IMETHOD_(PRInt32) ComputeFreeFloatingSpace(nsIIterator * aIterator); + NS_IMETHOD_(PRUint32) QueryNumberFloatingWidgets(nsIIterator * aIterator); + +}; + + + +#endif /* nsBoxLayout_h___ */ diff --git a/mozilla/xpfc/layout/inc/nsLayout.h b/mozilla/xpfc/layout/inc/nsLayout.h new file mode 100644 index 00000000000..9d1a95c0fc8 --- /dev/null +++ b/mozilla/xpfc/layout/inc/nsLayout.h @@ -0,0 +1,56 @@ +/* -*- 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 nsLayout_h___ +#define nsLayout_h___ + +#include "nsILayout.h" + +class nsLayout : public nsILayout +{ +public: + nsLayout(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + NS_IMETHOD Layout(); + + NS_IMETHOD PreferredSize(nsSize &aSize); + NS_IMETHOD MinimumSize(nsSize &aSize); + NS_IMETHOD MaximumSize(nsSize &aSize); + + NS_IMETHOD_(PRUint32) GetHorizontalGap(); + NS_IMETHOD_(PRUint32) GetVerticalGap(); + NS_IMETHOD_(void) SetHorizontalGap(PRUint32 aGapSize); + NS_IMETHOD_(void) SetVerticalGap(PRUint32 aGapSize); + + NS_IMETHOD_(PRFloat64) GetHorizontalFill(); + NS_IMETHOD_(PRFloat64) GetVerticalFill(); + NS_IMETHOD_(void) SetHorizontalFill(PRFloat64 aFillSize); + NS_IMETHOD_(void) SetVerticalFill(PRFloat64 aFillSize); + + +protected: + ~nsLayout(); + +}; + + + +#endif /* nsLayout_h___ */ diff --git a/mozilla/xpfc/layout/manifest.mn b/mozilla/xpfc/layout/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/layout/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/layout/public/Makefile b/mozilla/xpfc/layout/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/layout/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/layout/public/manifest.mn b/mozilla/xpfc/layout/public/manifest.mn new file mode 100644 index 00000000000..5990e475652 --- /dev/null +++ b/mozilla/xpfc/layout/public/manifest.mn @@ -0,0 +1,22 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsILayout.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/layout/public/nsILayout.h b/mozilla/xpfc/layout/public/nsILayout.h new file mode 100644 index 00000000000..363c1fd1a34 --- /dev/null +++ b/mozilla/xpfc/layout/public/nsILayout.h @@ -0,0 +1,55 @@ +/* -*- 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 nsILayout_h___ +#define nsILayout_h___ + +#include "nsISupports.h" +#include "nsSize.h" + +//914fc3a0-f73c-11d1-9244-00805f8a7ab6 +#define NS_ILAYOUT_IID \ +{ 0x914fc3a0, 0xf73c, 0x11d1, \ +{ 0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsILayout : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0 ; + + NS_IMETHOD Layout() = 0 ; + + NS_IMETHOD PreferredSize(nsSize &aSize) = 0 ; + NS_IMETHOD MinimumSize(nsSize &aSize) = 0 ; + NS_IMETHOD MaximumSize(nsSize &aSize) = 0 ; + + NS_IMETHOD_(PRUint32) GetHorizontalGap() = 0; + NS_IMETHOD_(PRUint32) GetVerticalGap() = 0; + NS_IMETHOD_(void) SetHorizontalGap(PRUint32 aGapSize) = 0; + NS_IMETHOD_(void) SetVerticalGap(PRUint32 aGapSize) = 0; + + NS_IMETHOD_(PRFloat64) GetHorizontalFill() = 0; + NS_IMETHOD_(PRFloat64) GetVerticalFill() = 0; + NS_IMETHOD_(void) SetHorizontalFill(PRFloat64 aFillSize) = 0; + NS_IMETHOD_(void) SetVerticalFill(PRFloat64 aFillSize) = 0; + +}; + +#endif /* nsILayout_h___ */ diff --git a/mozilla/xpfc/layout/src/Makefile b/mozilla/xpfc/layout/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/layout/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/layout/src/config.mk b/mozilla/xpfc/layout/src/config.mk new file mode 100644 index 00000000000..9ad9d465a91 --- /dev/null +++ b/mozilla/xpfc/layout/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = layout +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/layout/src/manifest.mn b/mozilla/xpfc/layout/src/manifest.mn new file mode 100644 index 00000000000..b34bcc1a45c --- /dev/null +++ b/mozilla/xpfc/layout/src/manifest.mn @@ -0,0 +1,26 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsLayout.cpp \ + nsBoxLayout.cpp \ + $(NULL) + +REQUIRES = xpcom raptor + diff --git a/mozilla/xpfc/layout/src/nsBoxLayout.cpp b/mozilla/xpfc/layout/src/nsBoxLayout.cpp new file mode 100644 index 00000000000..b365ad05b45 --- /dev/null +++ b/mozilla/xpfc/layout/src/nsBoxLayout.cpp @@ -0,0 +1,697 @@ +/* -*- 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. + */ + +/* + * Note that throughout this code we assume (from a performance perspective) + * that the number of widgets being laid out is very small (< 50). If this + * assumption does not hold, the massive while loops found in this logic + * should be optimized to be one for loop. + * + * This code is recommended as a clean way to layout small numbers of + * containers holding objects, in an extensible way. For large lists, + * use widgets geared towards them. + */ + +#include "nsxpfcCIID.h" + +#include "nsBoxLayout.h" +#include "nsIXPFCCanvas.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kBoxLayoutCID, NS_BOXLAYOUT_CID); +static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); + +nsBoxLayout :: nsBoxLayout() : nsLayout() +{ + NS_INIT_REFCNT(); + mContainer = nsnull; + mLayoutAlignment = eLayoutAlignment_horizontal; + mVerticalGap = 1; + mHorizontalGap = 1; + mVerticalFill = 1.0; + mHorizontalFill = 1.0; +} + +nsBoxLayout :: ~nsBoxLayout() +{ + NS_IF_RELEASE(mContainer); +} + + +nsresult nsBoxLayout::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + static NS_DEFINE_IID(kClassIID, kBoxLayoutCID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return (nsLayout::QueryInterface(aIID,aInstancePtr)); +} + +NS_IMPL_ADDREF(nsBoxLayout) +NS_IMPL_RELEASE(nsBoxLayout) + +nsresult nsBoxLayout :: Init() +{ + return NS_OK ; +} + +nsresult nsBoxLayout :: Init(nsIXPFCCanvas * aContainer) +{ + NS_IF_RELEASE(mContainer); + mContainer = aContainer; + NS_ADDREF(mContainer); + return NS_OK ; +} + +nsresult nsBoxLayout :: Layout() +{ + if (!mContainer) + return NS_OK; + + LayoutContainer(); + + LayoutChildren(); + + return NS_OK ; + + +} + +nsresult nsBoxLayout :: LayoutContainer() +{ + nsIIterator * iterator ; + nsIXPFCCanvas * canvas ; + nsRect rect; + PRUint32 width, height; + PRUint32 wsize, hsize; + PRUint32 count = 0; + PRBool bFloater = PR_FALSE; + PRInt32 spaceleft = 0; + PRInt32 space_per_object = 0; + PRUint32 totalfloaters = 0; + PRUint32 start = 0; + nsSize prefSize; + nsSize minSize; + nsSize maxSize; + PRUint32 startX = 0, startY = 0; + + // Default case is everyone gets equal space + mContainer->GetBounds(rect); + wsize = width = rect.width; + hsize = height = rect.height; + + // Iterate through the children + CreateIterator(&iterator); + + iterator->Init(); + + if (iterator->Count() == 0) + return NS_OK; + + if (GetLayoutAlignment() == eLayoutAlignment_horizontal) { + wsize /= iterator->Count(); + start = rect.x; + } else { + hsize /= iterator->Count(); + start = rect.y; + } + + startY = rect.y; + startX = rect.x; + + /* + * First, we need to see if there is a floater so that preferred sizes + * can be used + */ + + bFloater = CanLayoutUsingPreferredSizes(iterator); + + /* + * If we have atleast one floater, all the non-floaters will get their preferred + * sizes and the floaters will then *deal* with the remaining space. So, compute + * the remaining space here. + * + * Then, we lay out all widgets with a preferred size using that size. The + * remaining widgets will get the average size which is the remaining space + * divided by the number of floating objects + */ + + if (bFloater == PR_TRUE) { + + spaceleft = ComputeFreeFloatingSpace(iterator); + + totalfloaters = QueryNumberFloatingWidgets(iterator); + + /* + * XXX Need to deal with case where space left is not enough. + * See ComputeFreeFloatingSpace at bottom for comment. + * + * for now, just fallback on equal layout for all widgets + */ + + /* + * If spaceleft is negative, then no floaters are visible and we should + * give each canvas its preferred size. Some may not be visible. + */ + + if (spaceleft < 0) { + bFloater = PR_FALSE; + } else { + space_per_object = spaceleft / totalfloaters; + } + } + + + iterator->First(); + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + if (GetLayoutAlignment() == eLayoutAlignment_horizontal) { + + if (bFloater == PR_FALSE) + { + + if (canvas->HasPreferredSize() == PR_TRUE) { + + canvas->GetPreferredSize(prefSize); + + rect.x = start; + rect.width = prefSize.width; + + start += rect.width; + + } else { + + rect.x = start; + rect.width = 0; + + } + +// rect.x = wsize * count; +// rect.width = wsize; + + } else { + + /* + * In this case, if we have a preferred size, use it. + * If no preferred size, use the weighted size if it + * falls within min/max range, else use min/max + */ + + if (canvas->HasPreferredSize() == PR_TRUE) { + + canvas->GetPreferredSize(prefSize); + + rect.x = start; + rect.width = prefSize.width; + + start += rect.width; + + } + else { + + /* + * check to see that space_per_object is between min and max + * and if so, use it else use the min or max + */ + + PRBool bSetToMinMax = PR_FALSE; + + if (canvas->HasMinimumSize() == PR_TRUE) { + + canvas->GetMinimumSize(minSize); + + if (space_per_object < minSize.width) { + + rect.x = start; + rect.width = minSize.width; + + start += rect.width; + + bSetToMinMax = PR_TRUE; + + } + + } + + if (bSetToMinMax == PR_FALSE && canvas->HasMaximumSize() == PR_TRUE) { + + canvas->GetMaximumSize(maxSize); + + if (space_per_object > maxSize.width) { + + rect.x = start; + rect.width = maxSize.width; + + start += rect.width; + + } + + } + + /* + * Yeah, this object can fill space_per_object + */ + + if (bSetToMinMax == PR_FALSE) { + + rect.x = start; + rect.width = space_per_object; + + start += rect.width; + + } + + } + + } + + rect.height = (PRInt32) (hsize * mHorizontalFill) ; + rect.y = (((PRUint32)(height - rect.height)) >> 2) + startY ; + + canvas->SetBounds(rect); + + } else { + + if (bFloater == PR_FALSE) + { + if (canvas->HasPreferredSize() == PR_TRUE) { + + canvas->GetPreferredSize(prefSize); + + rect.y = start; + rect.height = prefSize.height; + + start += rect.height; + + } else { + + rect.y = start; + rect.height = 0; + + } + +// rect.y = hsize * count; +// rect.height = hsize; + + } else { + + /* + * In this case, if we have a preferred size, use it. + * If no preferred size, use the weighted size if it + * falls within min/max range, else use min/max + */ + + if (canvas->HasPreferredSize() == PR_TRUE) { + + canvas->GetPreferredSize(prefSize); + + rect.y = start; + rect.height = prefSize.height; + + start += rect.height; + + } + else { + + /* + * check to see that space_per_object is between min and max + * and if so, use it else use the min or max + */ + + PRBool bSetToMinMax = PR_FALSE; + + if (canvas->HasMinimumSize() == PR_TRUE) { + + canvas->GetMinimumSize(minSize); + + if (space_per_object < minSize.height) { + + rect.y = start; + rect.height = minSize.height; + + start += rect.height; + + bSetToMinMax = PR_TRUE; + + } + + } + + if (bSetToMinMax == PR_FALSE && canvas->HasMaximumSize() == PR_TRUE) { + + canvas->GetMaximumSize(maxSize); + + if (space_per_object > maxSize.height) { + + rect.y = start; + rect.height = maxSize.height; + + start += rect.height; + + } + + } + + /* + * Yeah, this object can fill space_per_object + */ + + if (bSetToMinMax == PR_FALSE) { + + rect.y = start; + rect.height = space_per_object; + + start += rect.height; + + } + + } + + } + + rect.width = (PRInt32) (wsize * mVerticalFill) ; + rect.x = (((PRUint32)(width - rect.width)) >> 2) + startX ; + + canvas->SetBounds(rect); + } + + count++; + iterator->Next(); + } + + NS_RELEASE(iterator); + + return NS_OK ; + +} + +nsresult nsBoxLayout :: LayoutChildren() +{ + nsIIterator * iterator ; + nsIXPFCCanvas * canvas; + nsresult res ; + + // Iterate through the children + CreateIterator(&iterator); + + iterator->Init(); + + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + canvas->Layout(); + + iterator->Next(); + } + + NS_RELEASE(iterator); + + return NS_OK ; + +} + +PRBool nsBoxLayout :: CanLayoutUsingPreferredSizes(nsIIterator * aIterator) +{ + + nsresult res; + nsIXPFCCanvas * canvas; + + aIterator->First(); + + while(!(aIterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) aIterator->CurrentItem(); + + if (canvas->HasPreferredSize() == PR_FALSE) + return PR_TRUE; + + aIterator->Next(); + } + + return PR_FALSE; +} + +PRUint32 nsBoxLayout :: QueryNumberFloatingWidgets(nsIIterator * aIterator) +{ + + nsresult res; + nsIXPFCCanvas * canvas; + PRUint32 count = 0; + + aIterator->First(); + + while(!(aIterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) aIterator->CurrentItem(); + + if (canvas->HasPreferredSize() == PR_FALSE) { + + count ++; + + } + + aIterator->Next(); + } + + return count; +} + +/* + * Compute free floating space. Start with full area and then subtract + * the preferred space of every absolutely positioned widget. + */ + +PRInt32 nsBoxLayout :: ComputeFreeFloatingSpace(nsIIterator * aIterator) +{ + + nsresult res; + nsIXPFCCanvas * canvas; + PRInt32 space = 0; + PRInt32 space_per_object = 0; + nsRect rect; + nsSize prefSize; + nsSize minSize; + nsSize maxSize; + PRUint32 totalfloaters = 0; + + /* + * compute overall layout size + */ + + mContainer->GetBounds(rect); + if (GetLayoutAlignment() == eLayoutAlignment_horizontal) { + space = rect.width; + } else { + space = rect.height; + } + + /* + * subtract off all the preferred sizes + */ + + aIterator->First(); + + while(!(aIterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) aIterator->CurrentItem(); + + if (canvas->HasPreferredSize() == PR_TRUE) + { + canvas->GetPreferredSize(prefSize); + + if (GetLayoutAlignment() == eLayoutAlignment_horizontal) + { + space -= prefSize.width; + } + else + { + space -= prefSize.height; + } + + } + + aIterator->Next(); + } + + + /* + * Now compute the temporary space per object + */ + + totalfloaters = QueryNumberFloatingWidgets(aIterator); + + space_per_object = space / totalfloaters; + + /* + * Ok, so now we know how to lay out preferred size widgets. + * Normally, the floating widgets would use 'spaceleft' space, + * but that amount *might* fall outside their preferred ranges. + * When it does fall outside, we can set that widget to the + * specified min/max, but the space remaining will be altered, + * so compute that now + */ + + + aIterator->First(); + + while(!(aIterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) aIterator->CurrentItem(); + + if (canvas->HasPreferredSize() == PR_FALSE) { + + /* + * Check to see if the space assigned for this widget + * falls within it's min/max range + */ + + if (canvas->HasMinimumSize() == PR_TRUE) { + + canvas->GetMinimumSize(minSize); + + if (GetLayoutAlignment() == eLayoutAlignment_horizontal) { + + if (space_per_object < minSize.width) + space -= (minSize.width - space_per_object); + + } else { + + if (space_per_object < minSize.height) + space -= (minSize.height - space_per_object); + + } + + } + + if (canvas->HasMaximumSize() == PR_TRUE) { + + canvas->GetMaximumSize(maxSize); + + if (GetLayoutAlignment() == eLayoutAlignment_horizontal) { + + if (space_per_object > maxSize.width) + space += (space_per_object - maxSize.width); + + } else { + + if (space_per_object < maxSize.height) + space += (space_per_object - maxSize.height); + + } + + } + + } + + + aIterator->Next(); + } + + + /* + * At this point, if space is positive, we are ready to lay out. + * If space is negative, we need to shrink the floaters which have + * a maximum specified by the amount we are negative by the total + * number of floaters (it's getting ugly, maybe we can clean up later) + * + * We'll leave that logic for the actual layout + */ + + + return space; +} + + +nsresult nsBoxLayout :: CreateIterator(nsIIterator ** aIterator) +{ + return (mContainer->CreateIterator(aIterator)); +} + + +nsresult nsBoxLayout :: PreferredSize(nsSize &aSize) +{ + return NS_OK ; +} +nsresult nsBoxLayout :: MinimumSize(nsSize &aSize) +{ + return NS_OK ; +} +nsresult nsBoxLayout :: MaximumSize(nsSize &aSize) +{ + return NS_OK ; +} + +PRFloat64 nsBoxLayout :: GetHorizontalFill() +{ + return mHorizontalFill ; +} +PRFloat64 nsBoxLayout :: GetVerticalFill() +{ + return mVerticalFill ; +} +void nsBoxLayout :: SetHorizontalFill(PRFloat64 aFillSize) +{ + mHorizontalFill = aFillSize; +} +void nsBoxLayout :: SetVerticalFill(PRFloat64 aFillSize) +{ + mVerticalFill = aFillSize; +} + +PRUint32 nsBoxLayout :: GetHorizontalGap() +{ + return mHorizontalGap ; +} +PRUint32 nsBoxLayout :: GetVerticalGap() +{ + return mVerticalGap ; +} +void nsBoxLayout :: SetHorizontalGap(PRUint32 aGapSize) +{ + mHorizontalGap = aGapSize; +} +void nsBoxLayout :: SetVerticalGap(PRUint32 aGapSize) +{ + mVerticalGap = aGapSize; +} + +void nsBoxLayout :: SetLayoutAlignment(nsLayoutAlignment aLayoutAlignment) +{ + mLayoutAlignment = aLayoutAlignment; +} + +nsLayoutAlignment nsBoxLayout :: GetLayoutAlignment() +{ + return mLayoutAlignment; +} diff --git a/mozilla/xpfc/layout/src/nsLayout.cpp b/mozilla/xpfc/layout/src/nsLayout.cpp new file mode 100644 index 00000000000..a0cac938b16 --- /dev/null +++ b/mozilla/xpfc/layout/src/nsLayout.cpp @@ -0,0 +1,116 @@ +/* -*- 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. + */ + +#include "nsxpfcCIID.h" + +#include "nsLayout.h" + + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kLayoutCID, NS_LAYOUT_CID); + +nsLayout :: nsLayout() +{ + NS_INIT_REFCNT(); +} + +nsLayout :: ~nsLayout() +{ +} + + +nsresult nsLayout::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + static NS_DEFINE_IID(kClassIID, kLayoutCID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMPL_ADDREF(nsLayout) +NS_IMPL_RELEASE(nsLayout) + +nsresult nsLayout :: Init() +{ + return NS_OK ; +} + +nsresult nsLayout :: Layout() +{ + return NS_OK ; +} + + +nsresult nsLayout :: PreferredSize(nsSize &aSize) +{ + return NS_OK ; +} +nsresult nsLayout :: MinimumSize(nsSize &aSize) +{ + return NS_OK ; +} +nsresult nsLayout :: MaximumSize(nsSize &aSize) +{ + return NS_OK ; +} +PRUint32 nsLayout :: GetHorizontalGap() +{ + return 0 ; +} +PRUint32 nsLayout :: GetVerticalGap() +{ + return 0 ; +} +void nsLayout :: SetHorizontalGap(PRUint32 aGapSize) +{ + return; +} +void nsLayout :: SetVerticalGap(PRUint32 aGapSize) +{ + return; +} + +PRFloat64 nsLayout :: GetHorizontalFill() +{ + return 1.0 ; +} +PRFloat64 nsLayout :: GetVerticalFill() +{ + return 1.0 ; +} +void nsLayout :: SetHorizontalFill(PRFloat64 aFillSize) +{ + return; +} +void nsLayout :: SetVerticalFill(PRFloat64 aFillSize) +{ + return; +} + diff --git a/mozilla/xpfc/network/Makefile b/mozilla/xpfc/network/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/network/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/network/commandserver/Makefile b/mozilla/xpfc/network/commandserver/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/network/commandserver/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/network/commandserver/inc/Makefile b/mozilla/xpfc/network/commandserver/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/network/commandserver/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/network/commandserver/inc/manifest.mn b/mozilla/xpfc/network/commandserver/inc/manifest.mn new file mode 100644 index 00000000000..a674b56b07e --- /dev/null +++ b/mozilla/xpfc/network/commandserver/inc/manifest.mn @@ -0,0 +1,18 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + nsCommandServer.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/network/commandserver/inc/nsCommandServer.h b/mozilla/xpfc/network/commandserver/inc/nsCommandServer.h new file mode 100644 index 00000000000..2e6c2a5db3f --- /dev/null +++ b/mozilla/xpfc/network/commandserver/inc/nsCommandServer.h @@ -0,0 +1,63 @@ +/* -*- 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 nsCommandServer_h___ +#define nsCommandServer_h___ + +#include "nsICommandServer.h" +#include "nspr.h" + +#define TCP_MESG_SIZE 1024 +#define TCP_SERVER_PORT 666 +#define NUM_TCP_CLIENTS 10 +#define NUM_TCP_CONNECTIONS_PER_CLIENT 5 +#define NUM_TCP_MESGS_PER_CONNECTION 10 +#define SERVER_MAX_BIND_COUNT 100 + +typedef struct buffer { + char data[TCP_MESG_SIZE * 2]; +} buffer; + +class nsCommandServer : public nsICommandServer +{ + +public: + nsCommandServer(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(nsIApplicationShell * aApplicationShell); + +protected: + ~nsCommandServer(); + +public: + NS_IMETHOD RunThread(); + NS_IMETHOD ExitThread(); + +private: + nsIApplicationShell * mApplicationShell; + PRMonitor * mExitMon; /* monitor to signal on exit */ + PRInt32 * mExitCounter; /* counter to decrement, before exit */ + PRInt32 mDatalen; /* bytes of data transfered in each read/write */ + PRInt32 mNumThreads; + PRMonitor * mServerMon; + PRNetAddr mServerAddr; +}; + +#endif /* nsCommandServer_h___ */ diff --git a/mozilla/xpfc/network/commandserver/manifest.mn b/mozilla/xpfc/network/commandserver/manifest.mn new file mode 100644 index 00000000000..5174916fdbe --- /dev/null +++ b/mozilla/xpfc/network/commandserver/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/network/commandserver/public/Makefile b/mozilla/xpfc/network/commandserver/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/network/commandserver/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/network/commandserver/public/manifest.mn b/mozilla/xpfc/network/commandserver/public/manifest.mn new file mode 100644 index 00000000000..c2c5699f3fd --- /dev/null +++ b/mozilla/xpfc/network/commandserver/public/manifest.mn @@ -0,0 +1,22 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. +DEPTH = ../../../../../.. + +EXPORTS = \ + nsICommandServer.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/network/commandserver/public/nsICommandServer.h b/mozilla/xpfc/network/commandserver/public/nsICommandServer.h new file mode 100644 index 00000000000..e03fa2c83bf --- /dev/null +++ b/mozilla/xpfc/network/commandserver/public/nsICommandServer.h @@ -0,0 +1,39 @@ +/* -*- 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 nsICommandServer_h___ +#define nsICommandServer_h___ + +#include "nsISupports.h" +#include "nsIApplicationShell.h" + +//37eac360-386e-11d2-9249-00805f8a7ab6 +#define NS_IXPFC_COMMAND_SERVER_IID \ +{ 0x37eac360, 0x386e, 0x11d2, \ +{ 0x92, 0x49, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsICommandServer : public nsISupports +{ + +public: + + NS_IMETHOD Init(nsIApplicationShell * aApplicationShell) = 0 ; + +}; + +#endif /* nsICommandServer_h___ */ diff --git a/mozilla/xpfc/network/commandserver/src/Makefile b/mozilla/xpfc/network/commandserver/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/network/commandserver/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/network/commandserver/src/config.mk b/mozilla/xpfc/network/commandserver/src/config.mk new file mode 100644 index 00000000000..c3e1b34aae7 --- /dev/null +++ b/mozilla/xpfc/network/commandserver/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = commandserver +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/network/commandserver/src/manifest.mn b/mozilla/xpfc/network/commandserver/src/manifest.mn new file mode 100644 index 00000000000..af4f294f88b --- /dev/null +++ b/mozilla/xpfc/network/commandserver/src/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsCommandServer.cpp \ + $(NULL) + +REQUIRES = xpcom raptor netlib xpfc + diff --git a/mozilla/xpfc/network/commandserver/src/nsCommandServer.cpp b/mozilla/xpfc/network/commandserver/src/nsCommandServer.cpp new file mode 100644 index 00000000000..c62aea7548f --- /dev/null +++ b/mozilla/xpfc/network/commandserver/src/nsCommandServer.cpp @@ -0,0 +1,288 @@ +/* -*- 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. + */ + +#include "nsCommandServer.h" +#include "nsxpfcCIID.h" +#include "nsxpfcutil.h" +#include "nsCRT.h" +#include "nsString.h" +#include "nsxpfcstrings.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCCommandServerCID, NS_XPFC_COMMAND_SERVER_CID); +static NS_DEFINE_IID(kICommandServerIID, NS_IXPFC_COMMAND_SERVER_IID); + +static void PR_CALLBACK CommandServerThread(void * arg); +static void PR_CALLBACK CommandServerClientThread(void * arg); + +nsIApplicationShell * gApplicationShell = nsnull; + +nsCommandServer :: nsCommandServer() +{ + NS_INIT_REFCNT(); + mApplicationShell = nsnull; + mExitMon = nsnull ; + mExitCounter = nsnull; + mDatalen = 0; + mNumThreads = 0; + mServerMon = nsnull; + nsCRT::memset(&mServerAddr, 0 , sizeof(mServerAddr)); + gApplicationShell = mApplicationShell; +} + +nsCommandServer :: ~nsCommandServer() +{ + NS_IF_RELEASE(mApplicationShell); +} + +NS_IMPL_QUERY_INTERFACE(nsCommandServer, kICommandServerIID) +NS_IMPL_ADDREF(nsCommandServer) +NS_IMPL_RELEASE(nsCommandServer) + +nsresult nsCommandServer :: Init(nsIApplicationShell * aApplicationShell) +{ + PRThread * t = nsnull ; + + mApplicationShell = aApplicationShell; + gApplicationShell = mApplicationShell; + NS_ADDREF(mApplicationShell); + + /* + * Let's launch a server on a separate thread here.... + */ + + mServerMon = PR_NewMonitor(); + PR_EnterMonitor(mServerMon); + + mExitMon = mServerMon; + mExitCounter = &mNumThreads; + + t = PR_CreateThread(PR_USER_THREAD, + CommandServerThread, + (void *)this, + PR_PRIORITY_NORMAL, + PR_LOCAL_THREAD, + PR_UNJOINABLE_THREAD, + 0); + mNumThreads++; + + /* + * Note, this is an indefinite wait. This is probably bad + * since we are executing on the application thread still! + * Theoretically, it should happen relatively fast. + */ + + PR_Wait(mServerMon,PR_INTERVAL_NO_TIMEOUT); + + PR_ExitMonitor(mServerMon); + + return NS_OK ; +} + + +/* + * Note: This routine runs on it's own thread + */ + +nsresult nsCommandServer :: RunThread() +{ + PRFileDesc * sockfd = nsnull; + PRNetAddr netaddr; + PRInt32 i = 0; + PRFileDesc *newsockfd; + PRThread *t; + + sockfd = PR_NewTCPSocket(); + + if (sockfd == nsnull) + return NS_OK; + + nsCRT::memset(&netaddr, 0 , sizeof(netaddr)); + + netaddr.inet.family = PR_AF_INET; + netaddr.inet.port = PR_htons(TCP_SERVER_PORT); + netaddr.inet.ip = PR_htonl(PR_INADDR_ANY); + + while (PR_Bind(sockfd, &netaddr) < 0) + { + if (PR_GetError() == PR_ADDRESS_IN_USE_ERROR) + { + netaddr.inet.port += 2; + if (i++ < SERVER_MAX_BIND_COUNT) + continue; + } + PR_Close(sockfd); + return NS_OK; + } + + if (PR_Listen(sockfd, 32) < 0) + { + PR_Close(sockfd); + return NS_OK; + } + + if (PR_GetSockName(sockfd, &netaddr) < 0) + { + PR_Close(sockfd); + return NS_OK; + } + + mServerAddr.inet.family = netaddr.inet.family; + mServerAddr.inet.port = netaddr.inet.port; + mServerAddr.inet.ip = netaddr.inet.ip; + + + /* + * Wake up the parent thread now. + */ + + PR_EnterMonitor(mServerMon); + PR_Notify(mServerMon); + PR_ExitMonitor(mServerMon); + + + /* + * Each time a client connects, spawn yet another thread to deal with + * the communication + */ + + for (i = 0; i < (NUM_TCP_CLIENTS * NUM_TCP_CONNECTIONS_PER_CLIENT); i++) + { + newsockfd = PR_Accept(sockfd, &netaddr, PR_INTERVAL_NO_TIMEOUT); + + if (newsockfd == nsnull) + { + PR_Close(sockfd); + return NS_OK; + } + + t = PR_CreateThread(PR_USER_THREAD, + CommandServerClientThread, + (void *)newsockfd, + PR_PRIORITY_NORMAL, + PR_LOCAL_THREAD, + PR_UNJOINABLE_THREAD, + 0); + } + + + + PR_Close(sockfd); + return NS_OK; + +} + +static void PR_CALLBACK CommandServerThread(void * arg) +{ + nsCommandServer * command_server = (nsCommandServer *) arg; + + command_server->RunThread(); + + command_server->ExitThread(); + +} + +static void PR_CALLBACK CommandServerClientThread(void * arg) +{ + PRFileDesc * sockfd = (PRFileDesc *) arg; + + buffer * in_buf; + PRInt32 bytes = TCP_MESG_SIZE; + PRInt32 bytes2 ; + PRInt32 j; + + in_buf = PR_NEW(buffer); + + if (in_buf != nsnull) + { + bytes2 = PR_Recv(sockfd, in_buf->data, bytes, 0, PR_INTERVAL_NO_TIMEOUT); + + if (bytes2 > 0) + { + nsString string = "BOBO"; + + string.SetString(in_buf->data, bytes2); + + // XXX: We really need an interface for receiving string results + // for CommandInvoker queries. Right now, we can dispatch + // commands (ie SetBackgroundColor) but we have no useful + // way of receiving the results of a query (ie GetBackgroundColor) + // + // I believe we really need to update the nsIXPFCObserver interface + // to allow yet a third string to be passed in which is the response + // results..... + // + // I believe sman had an idea on how to do these things, check my notes... + // + if (string.EqualsIgnoreCase(XPFC_STRING_HELP) || string.EqualsIgnoreCase(XPFC_STRING_QUESTIONMARK)) + { + + nsCRT::memset(in_buf->data, '\0', bytes); + + nsCRT::memcpy(in_buf->data, "Help Not Yet Implemented ... Sorry Steve!!!\n", bytes); + + } else { + + nsString reply("Command Received and Executed!!!\n"); + + gApplicationShell->ReceiveCommand(string, reply); + + nsCRT::memset(in_buf->data, '\0', bytes); + + if (reply.Length() == 0) + reply = "Command Received and Executed!!!\n"; + + char * cstring = reply.ToNewCString(); + + nsCRT::memcpy(in_buf->data, cstring, reply.Length()); + + delete cstring; + + } + + + + bytes2 = PR_Send(sockfd, in_buf->data, bytes, 0, PR_INTERVAL_NO_TIMEOUT); + + if (bytes2 <=0) + j = 0; + } + + PR_Shutdown(sockfd, PR_SHUTDOWN_BOTH); + + } + + PR_Close(sockfd); + + if (in_buf) { + PR_DELETE(in_buf); + } + +} + + +nsresult nsCommandServer :: ExitThread() +{ + PR_EnterMonitor(mExitMon); + --(*mExitCounter); + PR_Notify(mExitMon); + PR_ExitMonitor(mExitMon); + + return NS_OK; +} + diff --git a/mozilla/xpfc/network/manifest.mn b/mozilla/xpfc/network/manifest.mn new file mode 100644 index 00000000000..3defd94fb2e --- /dev/null +++ b/mozilla/xpfc/network/manifest.mn @@ -0,0 +1,14 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS = commandserver + diff --git a/mozilla/xpfc/observer/Makefile b/mozilla/xpfc/observer/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/observer/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/observer/inc/Makefile b/mozilla/xpfc/observer/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/observer/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/observer/inc/manifest.mn b/mozilla/xpfc/observer/inc/manifest.mn new file mode 100644 index 00000000000..c1ff2d9c235 --- /dev/null +++ b/mozilla/xpfc/observer/inc/manifest.mn @@ -0,0 +1,23 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + nsXPFCObserver.h \ + nsXPFCSubject.h \ + nsXPFCObserverManager.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/observer/inc/nsXPFCObserver.h b/mozilla/xpfc/observer/inc/nsXPFCObserver.h new file mode 100644 index 00000000000..5045909694c --- /dev/null +++ b/mozilla/xpfc/observer/inc/nsXPFCObserver.h @@ -0,0 +1,39 @@ +/* -*- 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 nsXPFCObserver_h___ +#define nsXPFCObserver_h___ + +#include "nsIXPFCObserver.h" + +class nsXPFCObserver : public nsIXPFCObserver +{ +public: + nsXPFCObserver(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init() ; + NS_IMETHOD Update(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand) ; + +protected: + ~nsXPFCObserver(); + +}; + +#endif /* nsXPFCObserver_h___ */ diff --git a/mozilla/xpfc/observer/inc/nsXPFCObserverManager.h b/mozilla/xpfc/observer/inc/nsXPFCObserverManager.h new file mode 100644 index 00000000000..4f77bd4f844 --- /dev/null +++ b/mozilla/xpfc/observer/inc/nsXPFCObserverManager.h @@ -0,0 +1,58 @@ +/* -*- 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 nsXPFCObserverManager_h___ +#define nsXPFCObserverManager_h___ + +#include "nscore.h" +#include "plstr.h" +#include "prtypes.h" +#include "prmon.h" +#include "plstr.h" +#include "nsCom.h" +#include "nsIVector.h" +#include "nsIIterator.h" + +#include "nsIXPFCObserverManager.h" + +class nsXPFCObserverManager : public nsIXPFCObserverManager +{ +public: + nsXPFCObserverManager(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init() ; + NS_IMETHOD Register(nsIXPFCSubject * aSubject, nsIXPFCObserver * aObserver); + NS_IMETHOD Unregister(nsISupports * aSubjectObserver); + NS_IMETHOD Unregister(nsIXPFCSubject * aSubject, nsIXPFCObserver * aObserver); + NS_IMETHOD Notify(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand); + +protected: + ~nsXPFCObserverManager(); + +public: + PRMonitor * monitor; + +public: + nsIVector * mList ; + nsIXPFCSubject * mCurrentSubject; + +}; + +#endif /* nsXPFCObserverManager_h___ */ diff --git a/mozilla/xpfc/observer/inc/nsXPFCSubject.h b/mozilla/xpfc/observer/inc/nsXPFCSubject.h new file mode 100644 index 00000000000..01bdbf45e51 --- /dev/null +++ b/mozilla/xpfc/observer/inc/nsXPFCSubject.h @@ -0,0 +1,44 @@ +/* -*- 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 nsXPFCSubject_h___ +#define nsXPFCSubject_h___ + +#include "nsIXPFCSubject.h" + + +class nsXPFCSubject : public nsIXPFCSubject +{ +public: + nsXPFCSubject(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init() ; + + NS_IMETHOD Attach(nsIXPFCObserver * aObserver); + NS_IMETHOD Detach(nsIXPFCObserver * aObserver); + NS_IMETHOD Notify(nsIXPFCCommand * aCommand); + + +protected: + ~nsXPFCSubject(); + +}; + +#endif /* nsXPFCSubject_h___ */ diff --git a/mozilla/xpfc/observer/manifest.mn b/mozilla/xpfc/observer/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/observer/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/observer/public/Makefile b/mozilla/xpfc/observer/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/observer/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/observer/public/manifest.mn b/mozilla/xpfc/observer/public/manifest.mn new file mode 100644 index 00000000000..594190f2289 --- /dev/null +++ b/mozilla/xpfc/observer/public/manifest.mn @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIXPFCObserver.h \ + nsIXPFCSubject.h \ + nsIXPFCObserverManager.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/observer/public/nsIXPFCObserver.h b/mozilla/xpfc/observer/public/nsIXPFCObserver.h new file mode 100644 index 00000000000..b5915896f0b --- /dev/null +++ b/mozilla/xpfc/observer/public/nsIXPFCObserver.h @@ -0,0 +1,42 @@ +/* -*- 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 nsIXPFCObserver_h___ +#define nsIXPFCObserver_h___ + +#include "nsISupports.h" + +class nsIXPFCSubject; +class nsIXPFCCommand; + +//1ed118a0-1f53-11d2-bed9-00805f8a8dbd +#define NS_IXPFC_OBSERVER_IID \ +{ 0x1ed118a0, 0x1f53, 0x11d2, \ +{ 0xbe, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +class nsIXPFCObserver : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; + NS_IMETHOD Update(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand) = 0; + +}; + +#endif /* nsIXPFCObserver_h___ */ diff --git a/mozilla/xpfc/observer/public/nsIXPFCObserverManager.h b/mozilla/xpfc/observer/public/nsIXPFCObserverManager.h new file mode 100644 index 00000000000..bcc8501207f --- /dev/null +++ b/mozilla/xpfc/observer/public/nsIXPFCObserverManager.h @@ -0,0 +1,47 @@ +/* -*- 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 nsIXPFCObserverManager_h___ +#define nsIXPFCObserverManager_h___ + +#include "nsISupports.h" + +class nsIXPFCSubject; +class nsIXPFCObserver; +class nsIXPFCCommand; + +//d28a5590-1f56-11d2-bed9-00805f8a8dbd +#define NS_IXPFC_OBSERVERMANAGER_IID \ +{ 0xd28a5590, 0x1f56, 0x11d2, \ +{ 0xbe, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +class nsIXPFCObserverManager : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; + + NS_IMETHOD Register(nsIXPFCSubject * aSubject, nsIXPFCObserver * aObserver) = 0; + NS_IMETHOD Unregister(nsISupports * aSubjectObserver) = 0; + NS_IMETHOD Unregister(nsIXPFCSubject * aSubject, nsIXPFCObserver * aObserver) = 0; + NS_IMETHOD Notify(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand) = 0; + +}; + +#endif /* nsIXPFCObserverManager_h___ */ diff --git a/mozilla/xpfc/observer/public/nsIXPFCSubject.h b/mozilla/xpfc/observer/public/nsIXPFCSubject.h new file mode 100644 index 00000000000..afd9b6bbb8a --- /dev/null +++ b/mozilla/xpfc/observer/public/nsIXPFCSubject.h @@ -0,0 +1,45 @@ +/* -*- 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 nsIXPFCSubject_h___ +#define nsIXPFCSubject_h___ + +#include "nsISupports.h" + +class nsIXPFCObserver; +class nsIXPFCCommand; + +//72c5bfd0-1f55-11d2-bed9-00805f8a8dbd +#define NS_IXPFC_SUBJECT_IID \ +{ 0x72c5bfd0, 0x1f55, 0x11d2, \ +{ 0xbe, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +class nsIXPFCSubject : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; + + NS_IMETHOD Attach(nsIXPFCObserver * aObserver) = 0; + NS_IMETHOD Detach(nsIXPFCObserver * aObserver) = 0; + NS_IMETHOD Notify(nsIXPFCCommand * aCommand) = 0; + +}; + +#endif /* nsIXPFCSubject_h___ */ diff --git a/mozilla/xpfc/observer/src/Makefile b/mozilla/xpfc/observer/src/Makefile new file mode 100644 index 00000000000..60df328e33a --- /dev/null +++ b/mozilla/xpfc/observer/src/Makefile @@ -0,0 +1,54 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/observer/src/config.mk b/mozilla/xpfc/observer/src/config.mk new file mode 100644 index 00000000000..e8362fac3c7 --- /dev/null +++ b/mozilla/xpfc/observer/src/config.mk @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC +INCLUDES +=-I../inc + +LIBRARY_NAME = observer +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) + diff --git a/mozilla/xpfc/observer/src/manifest.mn b/mozilla/xpfc/observer/src/manifest.mn new file mode 100644 index 00000000000..09bdd9eda4d --- /dev/null +++ b/mozilla/xpfc/observer/src/manifest.mn @@ -0,0 +1,27 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsXPFCObserver.cpp \ + nsXPFCSubject.cpp \ + nsXPFCObserverManager.cpp \ + $(NULL) + +REQUIRES = xpcom raptor + diff --git a/mozilla/xpfc/observer/src/nsXPFCObserver.cpp b/mozilla/xpfc/observer/src/nsXPFCObserver.cpp new file mode 100644 index 00000000000..19c73cf3046 --- /dev/null +++ b/mozilla/xpfc/observer/src/nsXPFCObserver.cpp @@ -0,0 +1,48 @@ +/* -*- 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. + */ + +#include "nsXPFCObserver.h" +#include "nsxpfcCIID.h" +#include "nsIXPFCSubject.h" +#include "nsIXPFCCommand.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kXPFCObserverIID, NS_IXPFC_OBSERVER_IID); + +nsXPFCObserver :: nsXPFCObserver() +{ + NS_INIT_REFCNT(); +} + +nsXPFCObserver :: ~nsXPFCObserver() +{ +} + +NS_IMPL_ADDREF(nsXPFCObserver) +NS_IMPL_RELEASE(nsXPFCObserver) +NS_IMPL_QUERY_INTERFACE(nsXPFCObserver, kXPFCObserverIID) + +nsresult nsXPFCObserver::Init() +{ + return NS_OK; +} + +nsresult nsXPFCObserver::Update(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand) +{ + return NS_OK; +} diff --git a/mozilla/xpfc/observer/src/nsXPFCObserverManager.cpp b/mozilla/xpfc/observer/src/nsXPFCObserverManager.cpp new file mode 100644 index 00000000000..d60dab6ed25 --- /dev/null +++ b/mozilla/xpfc/observer/src/nsXPFCObserverManager.cpp @@ -0,0 +1,228 @@ +/* -*- 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. + */ + +#include "nsXPFCObserverManager.h" +#include "nsIXPFCObserver.h" +#include "nsIXPFCSubject.h" +#include "nsIXPFCCommand.h" +#include "nsxpfcCIID.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kXPFCObserverManagerIID, NS_IXPFC_OBSERVERMANAGER_IID); +static NS_DEFINE_IID(kCXPFCObserverIID, NS_IXPFC_OBSERVER_IID); +static NS_DEFINE_IID(kCXPFCSubjectIID, NS_IXPFC_SUBJECT_IID); + +class ListEntry { +public: + nsIXPFCSubject * subject; + nsIXPFCObserver * observer; + + ListEntry(nsIXPFCSubject * aSubject, + nsIXPFCObserver * aObserver) { + subject = aSubject; + observer = aObserver; + } + ~ListEntry() { + } +}; + + +nsXPFCObserverManager :: nsXPFCObserverManager() +{ + NS_INIT_REFCNT(); + mList = nsnull; + monitor = nsnull; +} + +nsXPFCObserverManager :: ~nsXPFCObserverManager() +{ + NS_IF_RELEASE(mList); + PR_DestroyMonitor(monitor); +} + +NS_IMPL_ADDREF(nsXPFCObserverManager) +NS_IMPL_RELEASE(nsXPFCObserverManager) +NS_IMPL_QUERY_INTERFACE(nsXPFCObserverManager, kXPFCObserverManagerIID) + +nsresult nsXPFCObserverManager::Init() +{ + if (mList == nsnull) { + + static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID); + static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + + nsresult res = nsRepository::CreateInstance(kCVectorCID, + nsnull, + kCVectorCID, + (void **)&mList); + + if (NS_OK != res) + return res ; + + mList->Init(); + } + + if (monitor == nsnull) { + monitor = PR_NewMonitor(); + } + + return NS_OK; +} + + +nsresult nsXPFCObserverManager::Register(nsIXPFCSubject * aSubject, nsIXPFCObserver * aObserver) +{ + PR_EnterMonitor(monitor); + + mList->Append(new ListEntry(aSubject, aObserver)); + + PR_ExitMonitor(monitor); + + return NS_OK; +} + +nsresult nsXPFCObserverManager::Unregister(nsIXPFCSubject * aSubject, nsIXPFCObserver * aObserver) +{ + PR_EnterMonitor(monitor); + + /* + * We need to loop through looking for a match of both and then remove them + */ + nsIIterator * iterator; + + mList->CreateIterator(&iterator); + + iterator->Init(); + + ListEntry * item ; + + while(!(iterator->IsDone())) + { + item = (ListEntry *) iterator->CurrentItem(); + + if (item->subject == aSubject && item->observer == aObserver) + { + mList->Remove((nsComponent)item); + break; + } + + iterator->Next(); + } + + PR_ExitMonitor(monitor); + + return NS_OK; +} + +/* + * If an arbitrary object is passed in to unregister, we want to + * remove it from all lists containing it as either a subject OR + * observer + */ + +nsresult nsXPFCObserverManager::Unregister(nsISupports * aSubjectObserver) +{ + PR_EnterMonitor(monitor); + + /* + * See which interfaces the passed in object supports + */ + + nsIXPFCObserver * observer; + nsIXPFCSubject * subject; + + nsresult res = aSubjectObserver->QueryInterface(kCXPFCObserverIID, (void**)observer); + + if (NS_OK != res) + observer = nsnull; + + res = aSubjectObserver->QueryInterface(kCXPFCSubjectIID, (void**)subject); + + if (NS_OK != res) + subject = nsnull; + + /* + * If this object does not support either, it's not doing anything + */ + + if ((observer == nsnull) && (subject == nsnull)) { + NS_IF_RELEASE(subject); + NS_IF_RELEASE(observer); + return NS_OK; + } + + /* + * We need to loop through looking for a match of both and then remove them + */ + nsIIterator * iterator; + + mList->CreateIterator(&iterator); + + iterator->Init(); + + ListEntry * item ; + + while(!(iterator->IsDone())) + { + item = (ListEntry *) iterator->CurrentItem(); + + if (item->subject == subject || item->observer == observer) + { + mList->Remove((nsComponent)item); + break; + } + + iterator->Next(); + } + + PR_ExitMonitor(monitor); + + NS_IF_RELEASE(subject); + NS_IF_RELEASE(observer); + + return NS_OK; +} + + +nsresult nsXPFCObserverManager::Notify(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand) +{ + PR_EnterMonitor(monitor); + + nsIIterator * iterator; + + mList->CreateIterator(&iterator); + + iterator->Init(); + + ListEntry * item ; + + while(!(iterator->IsDone())) + { + item = (ListEntry *) iterator->CurrentItem(); + + if (item->subject == aSubject || aSubject == nsnull) + item->observer->Update(item->subject, aCommand); + + iterator->Next(); + } + + PR_ExitMonitor(monitor); + + return NS_OK; +} + diff --git a/mozilla/xpfc/observer/src/nsXPFCSubject.cpp b/mozilla/xpfc/observer/src/nsXPFCSubject.cpp new file mode 100644 index 00000000000..b445911dfaa --- /dev/null +++ b/mozilla/xpfc/observer/src/nsXPFCSubject.cpp @@ -0,0 +1,57 @@ +/* -*- 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. + */ + +#include "nsXPFCSubject.h" +#include "nsxpfcCIID.h" +#include "nsIXPFCCommand.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kXPFCSubjectIID, NS_IXPFC_SUBJECT_IID); + +nsXPFCSubject :: nsXPFCSubject() +{ + NS_INIT_REFCNT(); +} + +nsXPFCSubject :: ~nsXPFCSubject() +{ +} + +NS_IMPL_ADDREF(nsXPFCSubject) +NS_IMPL_RELEASE(nsXPFCSubject) +NS_IMPL_QUERY_INTERFACE(nsXPFCSubject, kXPFCSubjectIID) + +nsresult nsXPFCSubject::Init() +{ + return NS_OK; +} + +nsresult nsXPFCSubject::Attach(nsIXPFCObserver * aObserver) +{ + return NS_OK; +} + +nsresult nsXPFCSubject::Detach(nsIXPFCObserver * aObserver) +{ + return NS_OK; +} + +nsresult nsXPFCSubject::Notify(nsIXPFCCommand * aCommand) +{ + return NS_OK; +} diff --git a/mozilla/xpfc/parser/Makefile b/mozilla/xpfc/parser/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/parser/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/parser/inc/Makefile b/mozilla/xpfc/parser/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/parser/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/parser/inc/manifest.mn b/mozilla/xpfc/parser/inc/manifest.mn new file mode 100644 index 00000000000..bb89324e6a7 --- /dev/null +++ b/mozilla/xpfc/parser/inc/manifest.mn @@ -0,0 +1,21 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + nsXPFCXMLContentSink.h \ + nsXPFCXMLDTD.h \ + nsMenuManager.h \ + nsToolbarManager.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/parser/inc/nsMenuManager.h b/mozilla/xpfc/parser/inc/nsMenuManager.h new file mode 100644 index 00000000000..67596ee6c00 --- /dev/null +++ b/mozilla/xpfc/parser/inc/nsMenuManager.h @@ -0,0 +1,54 @@ +/* -*- 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 nsMenuManager_h___ +#define nsMenuManager_h___ + +#include "nsIMenuManager.h" +#include "nsIVector.h" +#include "nsIIterator.h" + +class nsMenuManager : public nsIMenuManager +{ + +public: + nsMenuManager(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar); + NS_IMETHOD_(nsIMenuBar *) GetMenuBar(); + NS_IMETHOD AddMenuContainer(nsIMenuContainer * aMenuContainer) ; + NS_IMETHOD_(nsIMenuItem *) MenuItemFromID(PRUint32 aID) ; + NS_IMETHOD_(PRUint32) GetID(); + NS_IMETHOD_(nsIXPFCCommandReceiver*) GetDefaultReceiver() ; + NS_IMETHOD SetDefaultReceiver(nsIXPFCCommandReceiver* aReceiver) ; + +protected: + ~nsMenuManager(); + +private: + nsIMenuBar * mMenuBar; + nsIVector * mMenuContainers; + PRUint32 mValidMenuID; + nsIXPFCCommandReceiver * mDefaultReceiver; + +}; + +#endif /* nsMenuManager_h___ */ diff --git a/mozilla/xpfc/parser/inc/nsToolbarManager.h b/mozilla/xpfc/parser/inc/nsToolbarManager.h new file mode 100644 index 00000000000..e021117683b --- /dev/null +++ b/mozilla/xpfc/parser/inc/nsToolbarManager.h @@ -0,0 +1,45 @@ +/* -*- 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 nsToolbarManager_h___ +#define nsToolbarManager_h___ + +#include "nsIToolbarManager.h" +#include "nsIVector.h" +#include "nsIIterator.h" + +class nsToolbarManager : public nsIToolbarManager +{ + +public: + nsToolbarManager(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + NS_IMETHOD AddToolbar(nsIXPFCToolbar * aToolbar); + +protected: + ~nsToolbarManager(); + +private: + nsIVector * mToolbars; + +}; + +#endif /* nsToolbarManager_h___ */ diff --git a/mozilla/xpfc/parser/inc/nsXPFCXMLContentSink.h b/mozilla/xpfc/parser/inc/nsXPFCXMLContentSink.h new file mode 100644 index 00000000000..f4e0dc65f38 --- /dev/null +++ b/mozilla/xpfc/parser/inc/nsXPFCXMLContentSink.h @@ -0,0 +1,93 @@ +/* -*- 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 NS_XPFCXMLCONTENTSINK +#define NS_XPFCXMLCONTENTSINK + +#include "nsIParserNode.h" +#include "nsIContentSink.h" +#include "nsString.h" +#include "nsIHTMLContentSink.h" +#include "nsIWebViewerContainer.h" +#include "nsxpfcCIID.h" +#include "nsIVector.h" +#include "nsIIterator.h" +#include "nsIStack.h" +#include "nsHTMLTokens.h" +#include "nsXPFCXMLDTD.h" +#include "nsIXMLParserObject.h" + +class nsXPFCXMLContentSink : public nsIHTMLContentSink +{ + +public: + + NS_DECL_ISUPPORTS + + nsXPFCXMLContentSink(); + virtual ~nsXPFCXMLContentSink(); + + // nsIContentSink + NS_IMETHOD OpenContainer(const nsIParserNode& aNode); + NS_IMETHOD CloseContainer(const nsIParserNode& aNode); + NS_IMETHOD AddLeaf(const nsIParserNode& aNode); + NS_IMETHOD WillBuildModel(void); + NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel); + NS_IMETHOD WillInterrupt(void); + NS_IMETHOD WillResume(void); + + // nsIHTMLContentSink + NS_IMETHOD PushMark(); + NS_IMETHOD SetTitle(const nsString& aValue); + NS_IMETHOD OpenHTML(const nsIParserNode& aNode); + NS_IMETHOD CloseHTML(const nsIParserNode& aNode); + NS_IMETHOD OpenHead(const nsIParserNode& aNode); + NS_IMETHOD CloseHead(const nsIParserNode& aNode); + NS_IMETHOD OpenBody(const nsIParserNode& aNode); + NS_IMETHOD CloseBody(const nsIParserNode& aNode); + NS_IMETHOD OpenForm(const nsIParserNode& aNode); + NS_IMETHOD CloseForm(const nsIParserNode& aNode); + NS_IMETHOD OpenMap(const nsIParserNode& aNode); + NS_IMETHOD CloseMap(const nsIParserNode& aNode); + NS_IMETHOD OpenFrameset(const nsIParserNode& aNode); + NS_IMETHOD CloseFrameset(const nsIParserNode& aNode); + + NS_IMETHOD SetViewerContainer(nsIWebViewerContainer * aViewerContainer); + +private: + NS_IMETHOD CIDFromTag(eXPFCXMLTags tag, nsCID &aClass); + NS_IMETHOD ConsumeAttributes(const nsIParserNode& aNode, nsIXMLParserObject& aObject); + NS_IMETHOD AddToHierarchy(nsIXMLParserObject& aObject, PRBool aPush); + +public: + NS_IMETHOD_(PRBool) IsContainer(const nsIParserNode& aNode); + + +private: + nsIWebViewerContainer * mViewerContainer ; + nsIStack * mXPFCStack; + nsIVector * mOrphanMenuList; + nsIVector * mContainerList ; + PRUint32 mState; + +}; + + +#endif + + diff --git a/mozilla/xpfc/parser/inc/nsXPFCXMLDTD.h b/mozilla/xpfc/parser/inc/nsXPFCXMLDTD.h new file mode 100644 index 00000000000..40f1c5130c6 --- /dev/null +++ b/mozilla/xpfc/parser/inc/nsXPFCXMLDTD.h @@ -0,0 +1,86 @@ +/* -*- 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 NS_XPFCXMLDTD__ +#define NS_XPFCXMLDTD__ + +#include "nsxpfc.h" +#include "CNavDTD.h" +#include "nsxpfcstrings.h" + +enum eXPFCXMLTags +{ + eXPFCXMLTag_unknown=0, + eXPFCXMLTag_doctype, + eXPFCXMLTag_xml, + + eXPFCXMLTag_button, + eXPFCXMLTag_canvas, + eXPFCXMLTag_dialog, + eXPFCXMLTag_editfield, + eXPFCXMLTag_menubar, + eXPFCXMLTag_menucontainer, + eXPFCXMLTag_menuitem, + eXPFCXMLTag_object, + eXPFCXMLTag_separator, + eXPFCXMLTag_set, + eXPFCXMLTag_tabwidget, + eXPFCXMLTag_toolbar, + eXPFCXMLTag_ui, + + eXPFCXMLTag_userdefined +}; + +enum eXPFCXMLAttributes +{ + eXPFCXMLAttr_unknown=0, + + eXPFCXMLAttr_key, + eXPFCXMLAttr_tag, + eXPFCXMLAttr_value, + + eXPFCXMLAttr_userdefined +}; + + +class nsXPFCXMLDTD : public CNavDTD { + + public: + + NS_DECL_ISUPPORTS + + nsXPFCXMLDTD(); + virtual ~nsXPFCXMLDTD(); + + virtual PRBool CanParse(nsString& aContentType, PRInt32 aVersion); + + virtual eAutoDetectResult AutoDetectContentType(nsString& aBuffer,nsString& aType); + + NS_IMETHOD HandleToken(CToken* aToken); + + virtual nsresult CreateNewInstance(nsIDTD** aInstancePtrResult); + + nsresult HandleStartToken(CToken* aToken); + nsresult HandleEndToken(CToken* aToken); + +private: + NS_IMETHOD_(eXPFCXMLTags) TagTypeFromObject(const nsIParserNode& aNode) ; + +}; + +#endif diff --git a/mozilla/xpfc/parser/manifest.mn b/mozilla/xpfc/parser/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/parser/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/parser/public/Makefile b/mozilla/xpfc/parser/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/parser/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/parser/public/manifest.mn b/mozilla/xpfc/parser/public/manifest.mn new file mode 100644 index 00000000000..c14aac9d529 --- /dev/null +++ b/mozilla/xpfc/parser/public/manifest.mn @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIXMLParserObject.h \ + nsIMenuManager.h \ + nsIToolbarManager.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/parser/public/nsIMenuManager.h b/mozilla/xpfc/parser/public/nsIMenuManager.h new file mode 100644 index 00000000000..f9bddccc4bd --- /dev/null +++ b/mozilla/xpfc/parser/public/nsIMenuManager.h @@ -0,0 +1,49 @@ +/* -*- 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 nsIMenuManager_h___ +#define nsIMenuManager_h___ + +#include "nsISupports.h" +#include "nsIMenuContainer.h" +#include "nsIXPFCCommandReceiver.h" + +class nsIMenuBar; + +//5e1180e0-30a9-11d2-9247-00805f8a7ab6 +#define NS_IMENU_MANAGER_IID \ +{ 0x5e1180e0, 0x30a9, 0x11d2, \ +{ 0x92, 0x47, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsIMenuManager : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0 ; + NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar) = 0; + NS_IMETHOD_(nsIMenuBar *) GetMenuBar() = 0; + NS_IMETHOD AddMenuContainer(nsIMenuContainer * aMenuContainer) = 0; + NS_IMETHOD_(nsIMenuItem *) MenuItemFromID(PRUint32 aID) = 0; + NS_IMETHOD_(PRUint32) GetID() = 0; + NS_IMETHOD_(nsIXPFCCommandReceiver*) GetDefaultReceiver() = 0; + NS_IMETHOD SetDefaultReceiver(nsIXPFCCommandReceiver* aReceiver) = 0; + +}; + +#endif /* nsIMenuManager_h___ */ diff --git a/mozilla/xpfc/parser/public/nsIToolbarManager.h b/mozilla/xpfc/parser/public/nsIToolbarManager.h new file mode 100644 index 00000000000..2510afe4f4e --- /dev/null +++ b/mozilla/xpfc/parser/public/nsIToolbarManager.h @@ -0,0 +1,42 @@ +/* -*- 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 nsIToolbarManager_h___ +#define nsIToolbarManager_h___ + +#include "nsISupports.h" +#include "nsIXPFCCommandReceiver.h" + +class nsIXPFCToolbar; + +//ba72e190-35f1-11d2-9248-00805f8a7ab6 +#define NS_ITOOLBAR_MANAGER_IID \ +{ 0xba72e190, 0x35f1, 0x11d2, \ +{ 0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsIToolbarManager : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0 ; + NS_IMETHOD AddToolbar(nsIXPFCToolbar * aToolbar) = 0; + +}; + +#endif /* nsIToolbarManager_h___ */ diff --git a/mozilla/xpfc/parser/public/nsIXMLParserObject.h b/mozilla/xpfc/parser/public/nsIXMLParserObject.h new file mode 100644 index 00000000000..59a617fa45c --- /dev/null +++ b/mozilla/xpfc/parser/public/nsIXMLParserObject.h @@ -0,0 +1,40 @@ +/* -*- 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 nsIXMLParserObject_h___ +#define nsIXMLParserObject_h___ + +#include "nsISupports.h" +#include "nsString.h" + +//4afe0210-273d-11d2-9246-00805f8a7ab6 +#define NS_IXML_PARSER_OBJECT_IID \ +{ 0x4afe0210, 0x273d, 0x11d2, \ +{ 0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsIXMLParserObject : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) = 0; + +}; + +#endif /* nsIXMLParserObject_h___ */ diff --git a/mozilla/xpfc/parser/src/Makefile b/mozilla/xpfc/parser/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/parser/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/parser/src/config.mk b/mozilla/xpfc/parser/src/config.mk new file mode 100644 index 00000000000..e35270cc449 --- /dev/null +++ b/mozilla/xpfc/parser/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include -I$(GDEPTH)/htmlparser/src + +LIBRARY_NAME = parser +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/parser/src/manifest.mn b/mozilla/xpfc/parser/src/manifest.mn new file mode 100644 index 00000000000..2e5db6af66c --- /dev/null +++ b/mozilla/xpfc/parser/src/manifest.mn @@ -0,0 +1,28 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsXPFCXMLContentSink.cpp \ + nsXPFCXMLDTD.cpp \ + nsMenuManager.cpp \ + nsToolbarManager.cpp \ + $(NULL) + +REQUIRES = xpcom raptor netlib xpfc + diff --git a/mozilla/xpfc/parser/src/nsMenuManager.cpp b/mozilla/xpfc/parser/src/nsMenuManager.cpp new file mode 100644 index 00000000000..3bd2fe2980f --- /dev/null +++ b/mozilla/xpfc/parser/src/nsMenuManager.cpp @@ -0,0 +1,117 @@ +/* -*- 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. + */ + +#include "nsMenuManager.h" +#include "nsxpfcCIID.h" +#include "nsxpfcutil.h" +#include "nsIMenuBar.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCMenuManagerCID, NS_MENU_MANAGER_CID); +static NS_DEFINE_IID(kIMenuManagerIID, NS_IMENU_MANAGER_IID); + +#define MENU_ID_OFFSET 1 + +nsMenuManager :: nsMenuManager() +{ + NS_INIT_REFCNT(); + mMenuBar = nsnull; + mMenuContainers = nsnull; + mValidMenuID = MENU_ID_OFFSET; +} + +nsMenuManager :: ~nsMenuManager() +{ + NS_IF_RELEASE(mMenuBar); + + if (mMenuContainers != nsnull) + { + mMenuContainers->RemoveAll(); + NS_RELEASE(mMenuContainers); + } + +} + +NS_IMPL_QUERY_INTERFACE(nsMenuManager, kIMenuManagerIID) +NS_IMPL_ADDREF(nsMenuManager) +NS_IMPL_RELEASE(nsMenuManager) + +nsresult nsMenuManager :: Init() +{ + static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + nsresult res = nsRepository::CreateInstance(kCVectorCID, + nsnull, + kCVectorCID, + (void **)&mMenuContainers); + + if (NS_OK != res) + return res ; + + mMenuContainers->Init(); + + return NS_OK ; +} + +nsresult nsMenuManager :: SetMenuBar(nsIMenuBar * aMenuBar) +{ + mMenuBar = aMenuBar; + NS_ADDREF(mMenuBar); + return NS_OK ; +} + +nsIMenuBar * nsMenuManager :: GetMenuBar() +{ + return (mMenuBar) ; +} + +nsIXPFCCommandReceiver * nsMenuManager :: GetDefaultReceiver() +{ + return (mDefaultReceiver) ; +} + +nsresult nsMenuManager :: SetDefaultReceiver(nsIXPFCCommandReceiver * aReceiver) +{ + mDefaultReceiver = aReceiver; + return (NS_OK) ; +} + +nsresult nsMenuManager::AddMenuContainer(nsIMenuContainer * aMenuContainer) +{ + mMenuContainers->Append(aMenuContainer); + return NS_OK; +} + +nsIMenuItem * nsMenuManager::MenuItemFromID(PRUint32 aID) +{ + nsIMenuItem * item = nsnull; + + if (mMenuBar) + item = mMenuBar->MenuItemFromID(aID); + + if (item != nsnull) + return item; + + return nsnull; +} + +PRUint32 nsMenuManager::GetID() +{ + mValidMenuID++; + return mValidMenuID; +} + diff --git a/mozilla/xpfc/parser/src/nsToolbarManager.cpp b/mozilla/xpfc/parser/src/nsToolbarManager.cpp new file mode 100644 index 00000000000..6a61dfa7fe3 --- /dev/null +++ b/mozilla/xpfc/parser/src/nsToolbarManager.cpp @@ -0,0 +1,69 @@ +/* -*- 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. + */ + +#include "nsToolbarManager.h" +#include "nsxpfcCIID.h" +#include "nsxpfcutil.h" +#include "nsIXPFCToolbar.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCToolbarManagerCID, NS_TOOLBAR_MANAGER_CID); +static NS_DEFINE_IID(kIToolbarManagerIID, NS_ITOOLBAR_MANAGER_IID); + +nsToolbarManager :: nsToolbarManager() +{ + NS_INIT_REFCNT(); + mToolbars = nsnull; +} + +nsToolbarManager :: ~nsToolbarManager() +{ + if (mToolbars != nsnull) + { + mToolbars->RemoveAll(); + NS_RELEASE(mToolbars); + } + +} + +NS_IMPL_QUERY_INTERFACE(nsToolbarManager, kIToolbarManagerIID) +NS_IMPL_ADDREF(nsToolbarManager) +NS_IMPL_RELEASE(nsToolbarManager) + +nsresult nsToolbarManager :: Init() +{ + static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + nsresult res = nsRepository::CreateInstance(kCVectorCID, + nsnull, + kCVectorCID, + (void **)&mToolbars); + + if (NS_OK != res) + return res ; + + mToolbars->Init(); + + return NS_OK ; +} + +nsresult nsToolbarManager :: AddToolbar(nsIXPFCToolbar * aToolbar) +{ + mToolbars->Append(aToolbar); + return NS_OK ; +} + diff --git a/mozilla/xpfc/parser/src/nsXPFCXMLContentSink.cpp b/mozilla/xpfc/parser/src/nsXPFCXMLContentSink.cpp new file mode 100644 index 00000000000..8d4befaf4e0 --- /dev/null +++ b/mozilla/xpfc/parser/src/nsXPFCXMLContentSink.cpp @@ -0,0 +1,828 @@ +/* -*- 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. + */ + +#include "nsHTMLTokens.h" +#include "nsXPFCXMLDTD.h" +#include "nsxpfcCIID.h" +#include "nsIXMLParserObject.h" +#include "nsXPFCXMLContentSink.h" +#include "nsIMenuBar.h" +#include "nsIMenuItem.h" +#include "nsIMenuContainer.h" +#include "nsIXPFCCanvas.h" +#include "nsIButton.h" +#include "nsITextWidget.h" +#include "nsITabWidget.h" +#include "nsWidgetsCID.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID); +static NS_DEFINE_IID(kClassIID, NS_XPFCXMLCONTENTSINK_IID); +static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID); +static NS_DEFINE_IID(kIXMLParserObjectIID, NS_IXML_PARSER_OBJECT_IID); +static NS_DEFINE_IID(kCMenuBarCID, NS_MENUBAR_CID); +static NS_DEFINE_IID(kCMenuItemCID, NS_MENUITEM_CID); +static NS_DEFINE_IID(kCMenuContainerCID, NS_MENUCONTAINER_CID); +static NS_DEFINE_IID(kCIMenuBarIID, NS_IMENUBAR_IID); +static NS_DEFINE_IID(kCIMenuItemIID, NS_IMENUITEM_IID); +static NS_DEFINE_IID(kCIMenuContainerIID, NS_IMENUCONTAINER_IID); +static NS_DEFINE_IID(kCXPFCToolbarCID, NS_XPFC_TOOLBAR_CID); +static NS_DEFINE_IID(kCIXPFCToolbarIID, NS_IXPFC_TOOLBAR_IID); +static NS_DEFINE_IID(kCXPFCDialogCID, NS_XPFC_DIALOG_CID); +static NS_DEFINE_IID(kCIXPFCDialogIID, NS_IXPFC_DIALOG_IID); +static NS_DEFINE_IID(kCXPFCCanvasCID, NS_XPFC_CANVAS_CID); +static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); +static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID); +static NS_DEFINE_IID(kCTextWidgetCID, NS_TEXTFIELD_CID); +static NS_DEFINE_IID(kCTabWidgetCID, NS_TABWIDGET_CID); +static NS_DEFINE_IID(kCXPFCButtonCID, NS_XPFC_BUTTON_CID); +static NS_DEFINE_IID(kCXPFCTabWidgetCID, NS_XPFC_TABWIDGET_CID); +static NS_DEFINE_IID(kCXPFCTextWidgetCID, NS_XPFC_TEXTWIDGET_CID); + +#define XPFC_PARSING_STATE_UNKNOWN 0 +#define XPFC_PARSING_STATE_TOOLBAR 1 +#define XPFC_PARSING_STATE_MENUBAR 2 +#define XPFC_PARSING_STATE_DIALOG 3 + +class ContainerListEntry { +public: + nsIXMLParserObject * object; + nsString container; + + ContainerListEntry(nsIXMLParserObject * aObject, + nsString aContainer) { + object = aObject; + container = aContainer; + } + ~ContainerListEntry() { + } +}; + + +nsXPFCXMLContentSink::nsXPFCXMLContentSink() : nsIHTMLContentSink() +{ + NS_INIT_REFCNT(); + mViewerContainer = nsnull; + mContainerList = nsnull; + + mState = XPFC_PARSING_STATE_UNKNOWN; + + static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + nsresult res = nsRepository::CreateInstance(kCVectorCID, + nsnull, + kCVectorCID, + (void **)&mOrphanMenuList); + + if (NS_OK != res) + return ; + + mOrphanMenuList->Init(); + + static NS_DEFINE_IID(kCStackCID, NS_STACK_CID); + + res = nsRepository::CreateInstance(kCStackCID, + nsnull, + kCStackCID, + (void **)&mXPFCStack); + + if (NS_OK != res) + return ; + + mXPFCStack->Init(); + + if (mContainerList == nsnull) { + + static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID); + static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + + nsresult res = nsRepository::CreateInstance(kCVectorCID, + nsnull, + kCVectorCID, + (void **)&mContainerList); + + if (NS_OK != res) + return ; + + mContainerList->Init(); + } + + + +} + +nsXPFCXMLContentSink::~nsXPFCXMLContentSink() +{ + NS_RELEASE(mOrphanMenuList); + NS_RELEASE(mXPFCStack); + + if (mContainerList != nsnull) { + mContainerList->RemoveAll(); + NS_RELEASE(mContainerList); + } +} + +NS_IMPL_ADDREF(nsXPFCXMLContentSink) +NS_IMPL_RELEASE(nsXPFCXMLContentSink) + + +nsresult nsXPFCXMLContentSink::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + + if(aIID.Equals(kISupportsIID)) { //do IUnknown... + *aInstancePtr = (nsIContentSink*)(this); + } + else if(aIID.Equals(kIContentSinkIID)) { //do nsIContentSink base class... + *aInstancePtr = (nsIContentSink*)(this); + } + else if(aIID.Equals(kIHTMLContentSinkIID)) { + *aInstancePtr = (nsIHTMLContentSink*)(this); + } + else if(aIID.Equals(kClassIID)) { //do this class... + *aInstancePtr = (nsXPFCXMLContentSink*)(this); + } + else { + *aInstancePtr=0; + return NS_NOINTERFACE; + } + ((nsISupports*) *aInstancePtr)->AddRef(); + return NS_OK; +} + + +/* + * this method gets invoked whenever a container type tag + * is encountered. + */ + +NS_IMETHODIMP nsXPFCXMLContentSink::OpenContainer(const nsIParserNode& aNode) +{ + nsIXMLParserObject * object = nsnull; + eXPFCXMLTags tag = (eXPFCXMLTags) aNode.GetNodeType(); + nsresult res; + nsCID aclass; + + if (eXPFCXMLTag_menubar == tag) + mState = XPFC_PARSING_STATE_MENUBAR; + else if (eXPFCXMLTag_toolbar == tag) + mState = XPFC_PARSING_STATE_TOOLBAR; + else if (eXPFCXMLTag_dialog == tag) + mState = XPFC_PARSING_STATE_DIALOG; + + nsString text = aNode.GetText(); + + res = CIDFromTag(tag, aclass); + + if (NS_OK != res) + return res ; + + res = nsRepository::CreateInstance(aclass, + nsnull, + kIXMLParserObjectIID, + (void **)&object); + + if (NS_OK != res) + return res ; + + object->Init(); + + /* + * ConsumeAttributes + */ + + ConsumeAttributes(aNode,*object); + AddToHierarchy(*object, PR_TRUE); + + /* + * If this is a menu bar, tell the widget. + * Probably want a general notification scheme for menubar + * changes + */ + + if (eXPFCXMLTag_menubar == tag) + { + nsIMenuBar * menubar; + res = object->QueryInterface(kCIMenuBarIID,(void**)&menubar); + + if (NS_OK == res) + { + mViewerContainer->SetMenuBar(menubar); + NS_RELEASE(menubar); + } + } + /* + * If this is a menu bar, tell the widget. + * Probably want a general notification scheme for menubar + * changes + */ + + if (eXPFCXMLTag_toolbar == tag) + { + + nsIXPFCToolbar * toolbar; + res = object->QueryInterface(kCIXPFCToolbarIID,(void**)&toolbar); + + if (NS_OK == res) + { + mViewerContainer->AddToolbar(toolbar); + NS_RELEASE(toolbar); + } + + } + + if (eXPFCXMLTag_dialog == tag) + { + + nsIXPFCDialog * dialog; + res = object->QueryInterface(kCIXPFCDialogIID,(void**)&dialog); + + if (NS_OK == res) + { + mViewerContainer->ShowDialog(dialog); + NS_RELEASE(dialog); + } + + } + + + return NS_OK; +} + + +NS_IMETHODIMP nsXPFCXMLContentSink::CloseContainer(const nsIParserNode& aNode) +{ + nsISupports * container = (nsISupports *)mXPFCStack->Pop(); + + /* + * If we popped the topmost canvas, lay it out + */ + + nsISupports * parent = (nsISupports *) mXPFCStack->Top(); + if (parent == nsnull && container != nsnull) + { + nsIXPFCCanvas * canvas ; + nsresult res = container->QueryInterface(kIXPFCCanvasIID,(void**)&canvas); + + if (res == NS_OK) + { + canvas->Layout(); + NS_RELEASE(canvas); + } + } + + NS_IF_RELEASE(container); + + return NS_OK; +} + + +NS_IMETHODIMP nsXPFCXMLContentSink::AddLeaf(const nsIParserNode& aNode) +{ + nsIXMLParserObject * object = nsnull; + eXPFCXMLTags tag = (eXPFCXMLTags) aNode.GetNodeType(); + nsresult res; + nsCID aclass; + + // XXX Til we implement separators + if (tag == eXPFCXMLTag_separator) + return NS_OK; + + /* + * The XML may specify this as a leaf, but it's parameters + * will reference a child object, in which case it's + * runtime is a container + */ + + if (IsContainer(aNode) == PR_TRUE) + { + res = OpenContainer(aNode); + CloseContainer(aNode); + return res; + } + + + nsString text = aNode.GetText(); + + res = CIDFromTag(tag, aclass); + + + res = nsRepository::CreateInstance(aclass, + nsnull, + kIXMLParserObjectIID, + (void **)&object); + + if (NS_OK != res) + return res ; + + object->Init(); + + ConsumeAttributes(aNode,*object); + AddToHierarchy(*object, PR_FALSE); + + // XXX: Need a way to identify that native widgets are + // involved! + if (tag == eXPFCXMLTag_button + || tag == eXPFCXMLTag_tabwidget + || tag == eXPFCXMLTag_editfield) + { + nsIXPFCCanvas * canvas = nsnull; + res = object->QueryInterface(kIXPFCCanvasIID,(void**)&canvas); + if (NS_OK == res) + { + canvas->CreateWidget(); + NS_RELEASE(canvas); + } + + } + + + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::PushMark() +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::OpenHTML(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::CloseHTML(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::OpenHead(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::CloseHead(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::SetTitle(const nsString& aValue) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::OpenBody(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::CloseBody(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::OpenForm(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::CloseForm(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::OpenMap(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::CloseMap(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::OpenFrameset(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::CloseFrameset(const nsIParserNode& aNode) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::WillBuildModel(void) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::DidBuildModel(PRInt32 aQualityLevel) +{ + + if (mState == XPFC_PARSING_STATE_MENUBAR) + { + nsIIterator * iterator; + + mContainerList->CreateIterator(&iterator); + + iterator->Init(); + + ContainerListEntry * item ; + + while(!(iterator->IsDone())) + { + item = (ContainerListEntry *) iterator->CurrentItem(); + + /* + * item->object is the parent container + * item->container is the name of the target child container + * + * There should be a nsIMenuContainer in the free list with this + * name. Let's find it, make it the child, and remove from free list + */ + + nsIIterator * iterator2 ; + nsIMenuContainer * menu_container; + nsString child; + + nsresult res = mOrphanMenuList->CreateIterator(&iterator2); + + if (NS_OK != res) + return nsnull; + + iterator2->Init(); + + while(!(iterator2->IsDone())) + { + menu_container = (nsIMenuContainer *) iterator2->CurrentItem(); + + + nsIMenuItem * container_item = nsnull; + + res = menu_container->QueryInterface(kCIMenuItemIID,(void**)&container_item); + + if (res == NS_OK) + { + + child = container_item->GetName(); + + if (child == item->container) { + + /* + * Set as child + */ + + nsIMenuContainer * parent = nsnull; + res = item->object->QueryInterface(kCIMenuContainerIID, (void**)&parent); + + if (res == NS_OK) + { + parent->AddChild((nsIMenuItem *)container_item); + } + + mOrphanMenuList->Remove(child); + break; + } + + NS_RELEASE(container_item); + } + + iterator2->Next(); + } + + NS_RELEASE(iterator2); + + iterator->Next(); + } + + NS_IF_RELEASE(iterator); + + mViewerContainer->UpdateMenuBar(); + } else if (mState == XPFC_PARSING_STATE_TOOLBAR) + { + mViewerContainer->UpdateToolbars(); + } + + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::WillInterrupt(void) +{ + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::WillResume(void) +{ + return NS_OK; +} + + +nsresult nsXPFCXMLContentSink::SetViewerContainer(nsIWebViewerContainer * aViewerContainer) +{ + mViewerContainer = aViewerContainer; + + return NS_OK; +} + + +/* + * Find the CID from the XML Tag Object + */ + +NS_IMETHODIMP nsXPFCXMLContentSink::CIDFromTag(eXPFCXMLTags tag, nsCID &aClass) +{ + switch(tag) + { + case eXPFCXMLTag_menuitem: + aClass = kCMenuItemCID; + break; + + case eXPFCXMLTag_menucontainer: + aClass = kCMenuContainerCID; + break; + + case eXPFCXMLTag_menubar: + aClass = kCMenuBarCID; + break; + + case eXPFCXMLTag_toolbar: + aClass = kCXPFCToolbarCID; + break; + + case eXPFCXMLTag_dialog: + aClass = kCXPFCDialogCID; + break; + + case eXPFCXMLTag_canvas: + case eXPFCXMLTag_separator: + aClass = kCXPFCCanvasCID; + break; + + case eXPFCXMLTag_editfield: + aClass = kCXPFCTextWidgetCID; + break; + + case eXPFCXMLTag_button: + aClass = kCXPFCButtonCID; + break; + + case eXPFCXMLTag_tabwidget: + aClass = kCXPFCTabWidgetCID; + break; + + default: + return (NS_ERROR_UNEXPECTED); + break; + } + + + return NS_OK; +} + +NS_IMETHODIMP nsXPFCXMLContentSink::ConsumeAttributes(const nsIParserNode& aNode, nsIXMLParserObject& aObject) +{ + PRInt32 i = 0; + nsString key,value; + nsString scontainer; + PRBool container = PR_FALSE; + + for (i = 0; i < aNode.GetAttributeCount(); i++) { + + key = aNode.GetKeyAt(i); + value = aNode.GetValueAt(i); + + key.StripChars("\""); + value.StripChars("\""); + + aObject.SetParameter(key,value); + + if (key.EqualsIgnoreCase(XPFC_STRING_CONTAINER)) { + container = PR_TRUE; + scontainer = value; + } + + } + + + eXPFCXMLTags tag = (eXPFCXMLTags) aNode.GetNodeType(); + + //if (container == PR_TRUE) + // aObject.SetParameter(nsString("popup"),nsString("popup")); + + /* + * If this object has something it wants to control, store away the string and source + * object. Later on, we'll walk the content tree Registering appropriate subjects + * and observers. + */ + + if (container == PR_TRUE) + { + mContainerList->Append(new ContainerListEntry(&aObject, scontainer)); + } + + return NS_OK; +} + +PRBool nsXPFCXMLContentSink::IsContainer(const nsIParserNode& aNode) +{ + PRInt32 i = 0; + nsString key; + PRBool container = PR_FALSE; + + for (i = 0; i < aNode.GetAttributeCount(); i++) { + + key = aNode.GetKeyAt(i); + key.StripChars("\""); + + if (key.EqualsIgnoreCase(XPFC_STRING_CONTAINER)) { + container = PR_TRUE; + break; + } + + } + + return container; +} + + +NS_IMETHODIMP nsXPFCXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject, PRBool aPush) +{ + + if (mState == XPFC_PARSING_STATE_TOOLBAR) + { + + nsIXPFCToolbar * container = nsnull; + nsIXPFCToolbar * parent = nsnull; + + nsresult res = aObject.QueryInterface(kCIXPFCToolbarIID,(void**)&container); + + parent = (nsIXPFCToolbar *) mXPFCStack->Top(); + + if (parent == nsnull) + { + mViewerContainer->GetToolbarManager()->AddToolbar(container); + } else { + + nsIXPFCCanvas * parent_canvas = nsnull; + nsIXPFCCanvas * child_canvas = nsnull; + + res = aObject.QueryInterface(kIXPFCCanvasIID,(void**)&child_canvas); + + if (NS_OK == res) + { + res = parent->QueryInterface(kIXPFCCanvasIID,(void**)&parent_canvas); + + if (NS_OK == res) + { + parent_canvas->AddChildCanvas(child_canvas); + + NS_RELEASE(parent_canvas); + } + + NS_RELEASE(child_canvas); + } + + } + + + if (aPush == PR_TRUE) + mXPFCStack->Push(container); + + return NS_OK; + + } else if (mState == XPFC_PARSING_STATE_MENUBAR) + { + + nsIMenuContainer * container = nsnull; + nsIMenuContainer * parent = nsnull; + + nsresult res = aObject.QueryInterface(kCIMenuContainerIID,(void**)&container); + + parent = (nsIMenuContainer *) mXPFCStack->Top(); + + if (NS_OK != res) + { + + /* + * Must be a menu item. Add as child to top of stack + */ + nsIMenuItem * item = nsnull; + + aObject.QueryInterface(kCIMenuItemIID,(void**)&item); + + parent->AddChild(item); + + item->SetMenuID(mViewerContainer->GetMenuManager()->GetID()); + item->SetReceiver(mViewerContainer->GetMenuManager()->GetDefaultReceiver()); + + NS_RELEASE(item); + + return res; + } + + + if (res == NS_OK && parent != nsnull) + { + nsIMenuItem * item = nsnull; + + nsresult res = aObject.QueryInterface(kCIMenuItemIID,(void**)&item); + + parent->AddChild(item); + + item->SetMenuID(mViewerContainer->GetMenuManager()->GetID()); + item->SetReceiver(mViewerContainer->GetMenuManager()->GetDefaultReceiver()); + + NS_RELEASE(item); + } + + if (parent == nsnull) + { + /* + * Add all toplevel menucontainer's to the menu manager + */ + + mViewerContainer->GetMenuManager()->AddMenuContainer(container); + + /* + * We probably can get rid of the orphanlist now that we + * have a menu manager. + */ + + mOrphanMenuList->Append(container); + } + + if (aPush == PR_TRUE) + mXPFCStack->Push(container); + + // NS_RELEASE(container); + + return NS_OK; + } else if (mState == XPFC_PARSING_STATE_DIALOG) + { + + nsIXPFCDialog * container = nsnull; + nsIXPFCDialog * parent = nsnull; + + nsresult res = aObject.QueryInterface(kCIXPFCDialogIID,(void**)&container); + + parent = (nsIXPFCDialog *) mXPFCStack->Top(); + + if (parent == nsnull) + { + //mViewerContainer->GetToolbarManager()->AddDialog(container); + + if (aPush == PR_TRUE) + mXPFCStack->Push(container); + + } else { + + nsIXPFCCanvas * parent_canvas = nsnull; + nsIXPFCCanvas * child_canvas = nsnull; + + res = aObject.QueryInterface(kIXPFCCanvasIID,(void**)&child_canvas); + + if (NS_OK == res) + { + res = parent->QueryInterface(kIXPFCCanvasIID,(void**)&parent_canvas); + + if (NS_OK == res) + { + parent_canvas->AddChildCanvas(child_canvas); + + //NS_RELEASE(parent_canvas); + } + + if (aPush == PR_TRUE) + mXPFCStack->Push(child_canvas); + + //NS_RELEASE(child_canvas); + } + + } + + return NS_OK; + + } + + else { + return NS_OK; + } + + return NS_OK; +} + diff --git a/mozilla/xpfc/parser/src/nsXPFCXMLDTD.cpp b/mozilla/xpfc/parser/src/nsXPFCXMLDTD.cpp new file mode 100644 index 00000000000..5942bc8f464 --- /dev/null +++ b/mozilla/xpfc/parser/src/nsXPFCXMLDTD.cpp @@ -0,0 +1,393 @@ +/* -*- 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. + */ + +#include "nsxpfcCIID.h" +#include "nsXPFCXMLDTD.h" +#include "nsParser.h" +#include "nsParserNode.h" +#include "nsXPFCXMLContentSink.h" +#include "nsHTMLTokens.h" +#include "nsParserCIID.h" +#include "nsCRT.h" +#include "nsxpfcstrings.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID); +static NS_DEFINE_IID(kClassIID, NS_IXPFCXML_DTD_IID); +static NS_DEFINE_IID(kBaseClassIID, NS_INAVHTML_DTD_IID); + +static NS_DEFINE_IID(kCParserNodeCID, NS_PARSER_NODE_IID); +static NS_DEFINE_IID(kCParserNodeIID, NS_IPARSER_NODE_IID); + +static const char* kMenuXMLTextContentType = "ui/menubar"; +static const char* kMenuXMLDocHeader= "GetTokenType(); + nsXPFCXMLDTD* theDTD=(nsXPFCXMLDTD*)aDTD; + + nsString& name = aToken->GetStringValueXXX(); + eXPFCXMLTags type = DetermineXPFCXMLTagType(name); + + if (type != eXPFCXMLTag_userdefined) + aToken->SetTypeID(type); + + if(aDTD) { + switch(theType) { + case eToken_start: + result=theDTD->HandleStartToken(aToken); break; + case eToken_end: + result=theDTD->HandleEndToken(aToken); break; + case eToken_comment: + result=theDTD->HandleCommentToken(aToken); break; + case eToken_entity: + result=theDTD->HandleEntityToken(aToken); break; + case eToken_attribute: + result=theDTD->HandleAttributeToken(aToken); break; + default: + result=0; + }//switch + }//if + return result; +} + + +nsresult nsXPFCXMLDTD::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + + if(aIID.Equals(kISupportsIID)) { //do IUnknown... + *aInstancePtr = (nsIDTD*)(this); + } + else if(aIID.Equals(kBaseClassIID)) { //do nav dtd base class... + *aInstancePtr = (CNavDTD*)(this); + } + else if(aIID.Equals(kIDTDIID)) { //do IParser base class... + *aInstancePtr = (nsIDTD*)(this); + } + else if(aIID.Equals(kClassIID)) { //do this class... + *aInstancePtr = (nsXPFCXMLDTD*)(this); + } + else { + *aInstancePtr=0; + return NS_NOINTERFACE; + } + ((nsISupports*) *aInstancePtr)->AddRef(); + return NS_OK; +} + +NS_IMPL_ADDREF(nsXPFCXMLDTD) +NS_IMPL_RELEASE(nsXPFCXMLDTD) + +nsXPFCXMLDTD::nsXPFCXMLDTD() : CNavDTD() +{ + NS_INIT_REFCNT(); +} + +nsXPFCXMLDTD::~nsXPFCXMLDTD() +{ +} + +PRBool nsXPFCXMLDTD::CanParse(nsString& aContentType, PRInt32 aVersion) +{ + if (aContentType == kMenuXMLTextContentType || aContentType == kToolbarXMLTextContentType || aContentType == kDialogXMLTextContentType) + return PR_TRUE; + + return PR_FALSE; +} + +eAutoDetectResult nsXPFCXMLDTD::AutoDetectContentType(nsString& aBuffer,nsString& aType) +{ + if ((aType == kMenuXMLTextContentType) || (aBuffer.Find(kMenuXMLDocHeader) != -1)) + { + aType = kMenuXMLTextContentType; + return eValidDetect; + } + + if ((aType == kToolbarXMLTextContentType) || (aBuffer.Find(kToolbarXMLDocHeader) != -1)) + { + aType = kToolbarXMLTextContentType; + return eValidDetect; + } + + if ((aType == kDialogXMLTextContentType) || (aBuffer.Find(kDialogXMLDocHeader) != -1)) + { + aType = kDialogXMLTextContentType; + return eValidDetect; + } + + return eUnknownDetect; +} + + +nsresult nsXPFCXMLDTD::HandleToken(CToken* aToken) +{ + nsresult result=NS_OK; + + if(aToken) { + + CHTMLToken* theToken= (CHTMLToken*)(aToken); + eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); + + result=XPFCXMLDispatchTokenHandler(theToken,this); + + } + return result; + +} + + + +nsresult nsXPFCXMLDTD::CreateNewInstance(nsIDTD** aInstancePtrResult) +{ + static NS_DEFINE_IID(kCCalXPFCXMLDTD, NS_IXPFCXML_DTD_IID); + + nsresult result = nsRepository::CreateInstance(kCCalXPFCXMLDTD, + nsnull, + kIDTDIID, + (void**) aInstancePtrResult); + + return (result); +} + + +nsresult nsXPFCXMLDTD::HandleStartToken(CToken* aToken) +{ + CStartToken * st = (CStartToken*)aToken; + eXPFCXMLTags tokenTagType = (eXPFCXMLTags) st->GetTypeID(); + nsCParserNode * attrNode = nsnull; + + //Begin by gathering up attributes... + static NS_DEFINE_IID(kCParserNodeCID, NS_PARSER_NODE_IID); + static NS_DEFINE_IID(kCParserNodeIID, NS_IPARSER_NODE_IID); + + nsresult result = nsRepository::CreateInstance(kCParserNodeCID, nsnull, kCParserNodeIID,(void**) &attrNode); + + if (NS_OK != result) + return result; + + attrNode->Init((CHTMLToken*)aToken,mLineNumber); + + PRInt16 attrCount=aToken->GetAttributeCount(); + result=(0==attrCount) ? NS_OK : CollectAttributes(*attrNode,attrCount); + + if (tokenTagType == eXPFCXMLTag_object) { + tokenTagType = TagTypeFromObject(*attrNode); + st->SetTypeID(tokenTagType); + } + + if(NS_OK==result) { + + switch(tokenTagType) { + + case eXPFCXMLTag_xml: + case eXPFCXMLTag_doctype: + case eXPFCXMLTag_ui: + break; + + /* + * the Panel Tag represents the core container object for layout + */ + + case eXPFCXMLTag_object: + case eXPFCXMLTag_menubar: + case eXPFCXMLTag_menucontainer: + case eXPFCXMLTag_toolbar: + case eXPFCXMLTag_canvas: + case eXPFCXMLTag_dialog: + { + mSink->OpenContainer(*attrNode); + } + break; + + case eXPFCXMLTag_menuitem: + case eXPFCXMLTag_button: + case eXPFCXMLTag_editfield: + case eXPFCXMLTag_separator: + case eXPFCXMLTag_tabwidget: + { + if (((nsXPFCXMLContentSink *)mSink)->IsContainer(*attrNode) == PR_TRUE) + st->SetTypeID(eXPFCXMLTag_menucontainer); + mSink->AddLeaf(*attrNode); + } + break; + + case eXPFCXMLTag_set: + break; + + default: + break; + } + } + + NS_RELEASE(attrNode); + + if(eHTMLTag_newline==tokenTagType) + mLineNumber++; + + return result; +} + +nsresult nsXPFCXMLDTD::HandleEndToken(CToken* aToken) +{ + + nsresult result=NS_OK; + CEndToken* et = (CEndToken*)(aToken); + eXPFCXMLTags tokenTagType=(eXPFCXMLTags)et->GetTypeID(); + nsCParserNode * attrNode = nsnull; + + static NS_DEFINE_IID(kCParserNodeCID, NS_PARSER_NODE_IID); + static NS_DEFINE_IID(kCParserNodeIID, NS_IPARSER_NODE_IID); + + result = nsRepository::CreateInstance(kCParserNodeCID, nsnull, kCParserNodeIID, (void**)&attrNode); + + if (NS_OK != result) + return result; + + attrNode->Init((CHTMLToken*)aToken,mLineNumber); + + if (tokenTagType == eXPFCXMLTag_object) { + tokenTagType = TagTypeFromObject(*attrNode); + et->SetTypeID(tokenTagType); + } + + switch(tokenTagType) { + + case eXPFCXMLTag_xml: + case eXPFCXMLTag_doctype: + case eXPFCXMLTag_ui: + + case eXPFCXMLTag_object: + case eXPFCXMLTag_menubar: + case eXPFCXMLTag_menucontainer: + case eXPFCXMLTag_toolbar: + case eXPFCXMLTag_canvas: + case eXPFCXMLTag_dialog: + { + mSink->CloseContainer(*attrNode); + } + break; + + case eXPFCXMLTag_menuitem: + case eXPFCXMLTag_editfield: + case eXPFCXMLTag_separator: + case eXPFCXMLTag_button: + case eXPFCXMLTag_tabwidget: + break; + + case eXPFCXMLTag_set: + break; + + + default: + break; + } + + NS_RELEASE(attrNode); + + return result; +} + +eXPFCXMLTags nsXPFCXMLDTD::TagTypeFromObject(const nsIParserNode& aNode) +{ + PRInt32 i = 0; + + for (i = 0; i < aNode.GetAttributeCount(); i++) { + + nsString key = aNode.GetKeyAt(i); + + key.StripChars("\""); + + if (key.EqualsIgnoreCase(XPFC_STRING_CLASS)) { + + nsString value = aNode.GetValueAt(i); + + value.StripChars("\""); + + if (value.EqualsIgnoreCase("button")) + return (eXPFCXMLTag_button); + else if (value.EqualsIgnoreCase("separator")) + return (eXPFCXMLTag_separator); + else if (value.EqualsIgnoreCase("editfield")) + return (eXPFCXMLTag_editfield); + else if (value.EqualsIgnoreCase("tabwidget")) + return (eXPFCXMLTag_tabwidget); + } + + } + + return (eXPFCXMLTag_unknown); + +} \ No newline at end of file diff --git a/mozilla/xpfc/shell/Makefile b/mozilla/xpfc/shell/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/shell/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/shell/inc/Makefile b/mozilla/xpfc/shell/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/shell/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/shell/inc/manifest.mn b/mozilla/xpfc/shell/inc/manifest.mn new file mode 100644 index 00000000000..af649f22925 --- /dev/null +++ b/mozilla/xpfc/shell/inc/manifest.mn @@ -0,0 +1,20 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + nsShellInstance.h \ + nsApplicationManager.h \ + nsStreamManager.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/shell/inc/nsApplicationManager.h b/mozilla/xpfc/shell/inc/nsApplicationManager.h new file mode 100644 index 00000000000..f0f200eab9d --- /dev/null +++ b/mozilla/xpfc/shell/inc/nsApplicationManager.h @@ -0,0 +1,104 @@ +/* -*- 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 __nsApplicationManager_h +#define __nsApplicationManager_h + + +#include "nscore.h" +#include "plstr.h" +#include "prtypes.h" +#include "prmon.h" +#include "plstr.h" +#include "nsCom.h" +#include "nsxpfc.h" +#include "nsHashtable.h" +#include "nsIShellInstance.h" +#include "nsIApplicationShell.h" + + +/** + * ModalMessage enumerations + */ +enum nsModalMessageType +{ + eModalMessage_ok, + eModalMessage_ok_cancel, +}; + + +// Application Manager - Manages Application Instances +class NS_XPFC nsApplicationManager +{ +public: + + /** + * Initialize the ApplicationManager + * @result The result of the initialization, NS_OK if no errors + */ + static nsresult Initialize(); + + /** + * Get the ShellInstance associated with an Application + * @param aApplicationShell - The Application Shell + * @param aShellInstance = The returned shell instance for this application + * @result The result of the initialization, NS_OK if no errors + */ + static nsresult GetShellInstance(nsIApplicationShell * aApplicationShell, + nsIShellInstance **aShellInstance); + + /** + * Set the ShellInstance associated with an Application + * @param aApplicationShell - The Application Shell + * @param aShellInstance =The Shell instance for this application + * @result The result of the initialization, NS_OK if no errors + */ + static nsresult SetShellAssociation(nsIApplicationShell * aApplicationShell, + nsIShellInstance *aShellInstance); + + /** + * Delete the Association of the ShellInstance with the Application + * @param aApplicationShell - The Application Shell + * @param aShellInstance =The Shell instance for this application + * @result The result of the initialization, NS_OK if no errors + */ + static nsresult DeleteShellAssociation(nsIApplicationShell * aApplicationShell, + nsIShellInstance *aShellInstance); + + /** + * Display an Application-wide Modal Message Box + * @param aMessage The Message String to display + * @param aTitle The String to display in title area + * @param aModalMessageType The type of Modal Message + * @result The result of the initialization, NS_OK if no errors + */ + static nsresult ModalMessage(const nsString &aMessage, const nsString &aTitle, nsModalMessageType aModalMessageType); + +private: + + static nsresult checkInitialized(); + +private: + + static PRMonitor * monitor; + static nsHashtable * applications; + + +}; + +#endif diff --git a/mozilla/xpfc/shell/inc/nsShellInstance.h b/mozilla/xpfc/shell/inc/nsShellInstance.h new file mode 100644 index 00000000000..f99b51205a8 --- /dev/null +++ b/mozilla/xpfc/shell/inc/nsShellInstance.h @@ -0,0 +1,159 @@ +/* -*- 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. + */ + +#include +#include "nsIApplicationShell.h" +#include "nsIFactory.h" +#include "nscore.h" +#include "nsweb.h" +#include "nsCRT.h" +#include "nsIShellInstance.h" + +class nsIPref; +class nsIAppShell; +class nsIStreamManager; +class nsIToolbarManager; +class nsIDeviceContext; + + +// platform independent native handle to application instance +typedef void * nsNativeApplicationInstance ; + +class nsShellInstance : public nsIShellInstance +{ +public: + + /** + * Constructor and Destructor + */ + + nsShellInstance(); + ~nsShellInstance(); + + void* operator new(size_t sz) { + void* rv = new char[sz]; + nsCRT::zero(rv, sz); + return rv; + } + + /** + * ISupports Interface + */ + NS_DECL_ISUPPORTS + + /** + * Initialize Method + * @result The result of the initialization, NS_OK if no errors + */ + NS_IMETHOD Init(); + + /** + * Event Loop Execution + * @result The result of the initialization, NS_OK if no errors + */ + NS_IMETHOD Run(); + + /** + * Application Wide Factory Registration + * @result The result of the initialization, NS_OK if no errors + */ + NS_IMETHOD RegisterFactories(); + + /** + * Get the native instance associated with this shell instance + * @result An opaque native instance pointer + */ + NS_IMETHOD_(void *) GetNativeInstance(); + + /** + * Set the Native Instance associated with this shell instance + * @param aNativeInstance The native instance + * @result None + */ + NS_IMETHOD_(void) SetNativeInstance(void * aNativeInstance); + + /** + * Get the Application Shell + * @result nsIApplicationShell Application Shell + */ + NS_IMETHOD_(nsIApplicationShell *) GetApplicationShell(); + + /** + * Set the Application Shell for this Instance + * @param aApplicationShell the Application Shell + * @result None + */ + NS_IMETHOD_(void) SetApplicationShell(nsIApplicationShell * aApplicationShell); + + /** + * Create a toplevel Application Window for this application + * @param nsRect Rect in screen coordinates of toplevel window + * @param aHandleEventFunction Event Loop Callbacl function + * @result a Pointer to the nsIWidget representing the toplevel Window + */ + NS_IMETHOD_(nsIWidget *) CreateApplicationWindow(nsIAppShell * aAppShell, + const nsRect &aRect) ; + + /** + * Show/Hide the toplevel Application Window + * @param show Boolean of PR_TRUE/PR_FALSE on whether to Show/Hide the window + * @result nsresult NS_OK upon successful completion + */ + NS_IMETHOD ShowApplicationWindow(PRBool show) ; + + /** + * Get the native window associated with the toplevel Application Instance + * @result Opaque handle to the application window native instance + */ + NS_IMETHOD_(void *) GetApplicationWindowNativeInstance() ; + + /** + * Get the widget associated with the toplevel Application Instance + * @result a Pointer to the nsIWidget representing the toplevel Window + */ + NS_IMETHOD_(nsIWidget *) GetApplicationWidget() ; + + /** + * Exit this application + * @result nsresult NS_OK upon succcessful completion + */ + NS_IMETHOD ExitApplication() ; + + NS_IMETHOD_(nsIPref *) GetPreferences() ; + + NS_IMETHOD_(nsIStreamManager *) GetStreamManager(); + + NS_IMETHOD_(nsIToolbarManager *) GetToolbarManager(); + + NS_IMETHOD_(EVENT_CALLBACK) GetShellEventCallback() ; + + NS_IMETHOD LaunchApplication(nsString& aApplication) ; + + +private: + nsNativeApplicationInstance mNativeInstance ; + nsIApplicationShell * mApplicationShell ; + nsIWidget * mApplicationWindow ; + nsIPref * mPref; + nsIStreamManager * mStreamManager; + nsIToolbarManager * mToolbarManager; + nsIDeviceContext * mDeviceContext; + +}; + + diff --git a/mozilla/xpfc/shell/inc/nsStreamManager.h b/mozilla/xpfc/shell/inc/nsStreamManager.h new file mode 100644 index 00000000000..39ff9a30b34 --- /dev/null +++ b/mozilla/xpfc/shell/inc/nsStreamManager.h @@ -0,0 +1,47 @@ +/* -*- 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. + */ + +#include "nscore.h" +#include "nsIFactory.h" +#include "nsIStreamManager.h" + +class nsStreamManager : public nsIStreamManager +{ +public: + + /** + * Constructor and Destructor + */ + + nsStreamManager(); + ~nsStreamManager(); + + /** + * ISupports Interface + */ + NS_DECL_ISUPPORTS + + /** + * Initialize Method + * @result The result of the initialization, NS_OK if no errors + */ + NS_IMETHOD Init(); + +}; + + diff --git a/mozilla/xpfc/shell/manifest.mn b/mozilla/xpfc/shell/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/shell/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/shell/public/Makefile b/mozilla/xpfc/shell/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/shell/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/shell/public/manifest.mn b/mozilla/xpfc/shell/public/manifest.mn new file mode 100644 index 00000000000..fcc60bd85bf --- /dev/null +++ b/mozilla/xpfc/shell/public/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIApplicationShell.h \ + nsIShellInstance.h \ + nsIWebViewerContainer.h\ + nsIStreamManager.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/shell/public/nsIApplicationShell.h b/mozilla/xpfc/shell/public/nsIApplicationShell.h new file mode 100644 index 00000000000..007f6d05a28 --- /dev/null +++ b/mozilla/xpfc/shell/public/nsIApplicationShell.h @@ -0,0 +1,57 @@ +/* -*- 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 nsIApplicationShell_h___ +#define nsIApplicationShell_h___ + +#include "nscore.h" +#include "nsxpfc.h" +#include "nsISupports.h" +#include "nsIShellInstance.h" +#include "nsIWidget.h" + +class nsIWebViewerContainer; + +#define NS_IAPPLICATIONSHELL_IID \ + { 0xaf9a93e0, 0xdebc, 0x11d1, \ + {0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +extern "C" nsresult NS_RegisterApplicationShellFactory(); + +// Application Shell Interface +class nsIApplicationShell : public nsISupports +{ +public: + + /** + * Initialize the ApplicationShell + * @result The result of the initialization, NS_OK if no errors + */ + NS_IMETHOD Init() = 0; + + NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent) = 0 ; + + NS_IMETHOD GetWebViewerContainer(nsIWebViewerContainer ** aWebViewerContainer) = 0; + + NS_IMETHOD StartCommandServer() = 0; + + NS_IMETHOD ReceiveCommand(nsString& aCommand, nsString& aReply) = 0; + +}; + +#endif /* nsIApplicationShell_h___ */ diff --git a/mozilla/xpfc/shell/public/nsIShellInstance.h b/mozilla/xpfc/shell/public/nsIShellInstance.h new file mode 100644 index 00000000000..54a7101d8f1 --- /dev/null +++ b/mozilla/xpfc/shell/public/nsIShellInstance.h @@ -0,0 +1,145 @@ +/* -*- 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 nsIShellInstance_h___ +#define nsIShellInstance_h___ + +#include "nscore.h" +#include "nsxpfc.h" +#include "nsISupports.h" +#include "nsIApplicationShell.h" +#include "nsIWidget.h" + +class nsIApplicationShell; +class nsIPref; +class nsIAppShell; +class nsIStreamManager; +class nsIToolbarManager; + +#define NS_IXPFC_SHELL_INSTANCE_IID \ + { 0xbf88e640, 0xdf99, 0x11d1, \ + {0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + + +// An Interface for interacting with a specific Application Instance +class nsIShellInstance : public nsISupports +{ +public: + + /** + * Initialize the ShellInstance + * @result The result of the initialization, NS_Ok if no errors + */ + NS_IMETHOD Init() = 0; + + /** + * Start the Shell's Event Loop. + * @result The result of the event loop execution, NS_Ok if appropriate Exit Message occured + */ + NS_IMETHOD Run() = 0; + + /** + * Get Platform Specific Native Instance Handle representing this application + * @result An opaque pointer to the native application instance + */ + NS_IMETHOD_(void *) GetNativeInstance() = 0; + + /** + * Set the Platform Specific Native Instance Handle representing this application + * @param aNativeInstance Opaque handle to the native instance + * @result none + */ + NS_IMETHOD_(void) SetNativeInstance(void * aNativeInstance) = 0; + + /** + * Get a Handle to the ApplicationShell Interface for this Instance + * @result nsIApplicationShell* a Pointer to the ApplicationShell + */ + NS_IMETHOD_(nsIApplicationShell *) GetApplicationShell() = 0; + + /** + * Set a Handle to the ApplicationShell Interface for this Instance + * @param aApplicationShell nsIApplicationShell Object + * @result none + */ + NS_IMETHOD_(void) SetApplicationShell(nsIApplicationShell * aApplicationShell) = 0; + + /** + * Create a toplevel Application Window for this application + * @param nsRect Rect in screen coordinates of toplevel window + * @param aHandleEventFunction Event Loop Callbacl function + * @result a Pointer to the nsIWidget representing the toplevel Window + */ + NS_IMETHOD_(nsIWidget *) CreateApplicationWindow(nsIAppShell * aAppShell, + const nsRect &aRect) = 0 ; + + NS_IMETHOD_(EVENT_CALLBACK) GetShellEventCallback() = 0; + + /** + * Show/Hide the toplevel Application Window + * @param show Boolean of PR_TRUE/PR_FALSE on whether to Show/Hide the window + * @result nsresult NS_OK upon successful completion + */ + NS_IMETHOD ShowApplicationWindow(PRBool show) = 0 ; + + /** + * Get the native window associated with the toplevel Application Instance + * @result Opaque handle to the application window native instance + */ + NS_IMETHOD_(void *) GetApplicationWindowNativeInstance() = 0; + + /** + * Get the widget associated with the toplevel Application Instance + * @result a Pointer to the nsIWidget representing the toplevel Window + */ + NS_IMETHOD_(nsIWidget *) GetApplicationWidget() = 0; + + /** + * Exit this application + * @result nsresult NS_OK upon succcessful completion + */ + NS_IMETHOD ExitApplication() = 0 ; + + /** + * Get Preferences Object + * @result An nsIPref pointer + */ + NS_IMETHOD_(nsIPref *) GetPreferences() = 0; + + /** + * Get Stream Manager + * @result An nsIStreamManager pointer + */ + NS_IMETHOD_(nsIStreamManager *) GetStreamManager() = 0; + + /** + * Get Toolbar Manager + * @result An nsIToolbarManager pointer + */ + NS_IMETHOD_(nsIToolbarManager *) GetToolbarManager() = 0; + + /** + * Launch an application + * @result nsresult NS_OK upon succcessful completion + */ + NS_IMETHOD LaunchApplication(nsString& aApplication) = 0 ; + +}; + +#endif /* nsIShellInstance_h___ */ + diff --git a/mozilla/xpfc/shell/public/nsIStreamManager.h b/mozilla/xpfc/shell/public/nsIStreamManager.h new file mode 100644 index 00000000000..51c4f401552 --- /dev/null +++ b/mozilla/xpfc/shell/public/nsIStreamManager.h @@ -0,0 +1,45 @@ +/* -*- 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 nsIStreamManager_h___ +#define nsIStreamManager_h___ + +#include "nscore.h" +#include "nsxpfc.h" +#include "nsISupports.h" + +// 5f680140-360f-11d2-9248-00805f8a7ab6 +#define NS_ISTREAM_MANAGER_IID \ + { 0x5f680140, 0x360f, 0x11d2, \ + {0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +// Application Shell Interface +class nsIStreamManager : public nsISupports +{ +public: + + /** + * Initialize the StreamManager + * @result The result of the initialization, NS_OK if no errors + */ + NS_IMETHOD Init() = 0; + + +}; + +#endif /* nsIStreamManager_h___ */ diff --git a/mozilla/xpfc/shell/public/nsIWebViewerContainer.h b/mozilla/xpfc/shell/public/nsIWebViewerContainer.h new file mode 100644 index 00000000000..e8c724509dc --- /dev/null +++ b/mozilla/xpfc/shell/public/nsIWebViewerContainer.h @@ -0,0 +1,67 @@ +/* -*- 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 nsIWebViewerContainer_h___ +#define nsIWebViewerContainer_h___ + +#include "nsIContentViewer.h" +#include "nsIParser.h" +#include "nsIMenuManager.h" +#include "nsIMenuBar.h" +#include "nsIWebShell.h" +#include "nsIToolbarManager.h" +#include "nsIXPFCToolbar.h" +#include "nsIXPFCDialog.h" +#include "nsIApplicationShell.h" + +//06245670-306a-11d2-9247-00805f8a7ab6 +#define NS_IWEB_VIEWER_CONTAINER_IID \ +{ 0x06245670, 0x306a, 0x11d2, \ +{ 0x92, 0x47, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsIWebViewerContainer : public nsIContentViewerContainer +{ + +public: + + NS_IMETHOD SetMenuManager(nsIMenuManager * aMenuManager) = 0; + NS_IMETHOD_(nsIMenuManager *) GetMenuManager() = 0; + NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar) = 0; + NS_IMETHOD UpdateMenuBar() = 0; + + NS_IMETHOD SetToolbarManager(nsIToolbarManager * aToolbarManager) = 0; + NS_IMETHOD_(nsIToolbarManager *) GetToolbarManager() = 0; + NS_IMETHOD AddToolbar(nsIXPFCToolbar * aToolbar) = 0; + NS_IMETHOD RemoveToolbar(nsIXPFCToolbar * aToolbar) = 0; + NS_IMETHOD UpdateToolbars() = 0; + + NS_IMETHOD ShowDialog(nsIXPFCDialog * aDialog) = 0; + + NS_IMETHOD SetApplicationShell(nsIApplicationShell* aShell) = 0; + NS_IMETHOD GetApplicationShell(nsIApplicationShell*& aResult) = 0; + + NS_IMETHOD SetContentViewer(nsIContentViewer* aViewer) = 0; + NS_IMETHOD GetContentViewer(nsIContentViewer*& aResult) = 0; + + NS_IMETHOD LoadURL(const nsString& aURLSpec, + nsIStreamObserver* aListener, + nsIPostData* aPostData = 0) = 0; + +}; + + +#endif /* nsWebViewerContainer_h___ */ diff --git a/mozilla/xpfc/shell/src/Makefile b/mozilla/xpfc/shell/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/shell/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/shell/src/config.mk b/mozilla/xpfc/shell/src/config.mk new file mode 100644 index 00000000000..bafd329a3cd --- /dev/null +++ b/mozilla/xpfc/shell/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = shell +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/shell/src/manifest.mn b/mozilla/xpfc/shell/src/manifest.mn new file mode 100644 index 00000000000..f4e0e94fac1 --- /dev/null +++ b/mozilla/xpfc/shell/src/manifest.mn @@ -0,0 +1,29 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +DIRS = $(PLATFORM_DIRECTORY) + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsApplicationManager.cpp \ + nsShellInstance.cpp \ + nsStreamManager.cpp \ + $(NULL) + +REQUIRES = xpcom raptor pref js netlib + diff --git a/mozilla/xpfc/shell/src/nsApplicationManager.cpp b/mozilla/xpfc/shell/src/nsApplicationManager.cpp new file mode 100644 index 00000000000..a372288116d --- /dev/null +++ b/mozilla/xpfc/shell/src/nsApplicationManager.cpp @@ -0,0 +1,201 @@ +/* -*- 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 "nscore.h" + +#ifdef NS_WIN32 +#include "windows.h" +#elif NS_UNIX +#include +#endif + +#include "nsApplicationManager.h" +#include "nsString.h" + +nsHashtable * nsApplicationManager::applications = NULL; +PRMonitor *nsApplicationManager::monitor = NULL; + +class ApplicationEntry { +public: + nsIApplicationShell * applicationshell; + nsIShellInstance * shellinstance; + + ApplicationEntry(nsIApplicationShell * aApplicationShell, + nsIShellInstance * aShellInstance) { + applicationshell = aApplicationShell; + shellinstance = aShellInstance; + } + ~ApplicationEntry() { + } +}; + +class AppKey: public nsHashKey { +private: + nsIApplicationShell * applicationshell; + +public: + AppKey(nsIApplicationShell * aApplicationShell) { + applicationshell = aApplicationShell; + } + + PRUint32 HashValue(void) const { + return ((PRUint32) (applicationshell)); + } + + PRBool Equals(const nsHashKey *aKey) const { + return ((PRBool)(applicationshell == ((AppKey *)aKey)->applicationshell)); + } + + nsHashKey *Clone(void) const { + return new AppKey(applicationshell); + } +}; + + + +nsresult nsApplicationManager::GetShellInstance(nsIApplicationShell * aApplicationShell, + nsIShellInstance **aShellInstance) +{ + checkInitialized(); + + if (aShellInstance == NULL) { + return NS_ERROR_NULL_POINTER; + } + + PR_EnterMonitor(monitor); + + AppKey key(aApplicationShell); + ApplicationEntry *entry = (ApplicationEntry*) applications->Get(&key); + + nsresult res = NS_ERROR_FAILURE; + + PR_ExitMonitor(monitor); + + if (entry != NULL) { + *aShellInstance = entry->shellinstance; + (*aShellInstance)->AddRef(); + res = NS_OK; + } + + return res; +} + +nsresult nsApplicationManager::checkInitialized() +{ + nsresult res = NS_OK; + if (applications == NULL) { + res = Initialize(); + } + return res; +} + +nsresult nsApplicationManager::Initialize() +{ + if (applications == NULL) { + applications = new nsHashtable(); + } + if (monitor == NULL) { + monitor = PR_NewMonitor(); + } + + return NS_OK; +} + + +nsresult nsApplicationManager::SetShellAssociation(nsIApplicationShell * aApplicationShell, + nsIShellInstance *aShellInstance) +{ + checkInitialized(); + + nsIShellInstance *old = NULL; + GetShellInstance(aApplicationShell, &old); + + if (old != NULL) { + old->Release(); + return NS_ERROR_FAILURE; + } + + PR_EnterMonitor(monitor); + + AppKey key(aApplicationShell); + applications->Put(&key, new ApplicationEntry(aApplicationShell, aShellInstance)); + + PR_ExitMonitor(monitor); + + return NS_OK; +} + +nsresult nsApplicationManager::DeleteShellAssociation(nsIApplicationShell * aApplicationShell, + nsIShellInstance *aShellInstance) +{ + checkInitialized(); + + nsIShellInstance *old = NULL; + GetShellInstance(aApplicationShell, &old); + + nsresult res = NS_ERROR_FACTORY_NOT_REGISTERED; + if (old != nsnull) { + if (old == aShellInstance) { + PR_EnterMonitor(monitor); + + AppKey key(aApplicationShell); + ApplicationEntry *entry = (ApplicationEntry *) applications->Remove(&key); + delete entry; + + PR_ExitMonitor(monitor); + + res = NS_OK; + } + old->Release(); + } + + return res; +} + +nsresult nsApplicationManager::ModalMessage(const nsString &aMessage, + const nsString &aTitle, + nsModalMessageType aModalMessageType) +{ + + nsresult res = NS_OK ; + +#ifdef NS_WIN32 + + PRInt32 msgtype ; + + switch (aModalMessageType) + { + case eModalMessage_ok: + msgtype = MB_OK ; + break ; + + case eModalMessage_ok_cancel: + msgtype = MB_OK ; + break ; + + default: + msgtype = MB_OK ; + break ; + + } + ::MessageBox(NULL, (const char *)aMessage.GetUnicode(), (const char *)aTitle.GetUnicode(), msgtype); + +#endif + + return res ; +} diff --git a/mozilla/xpfc/shell/src/nsShellInstance.cpp b/mozilla/xpfc/shell/src/nsShellInstance.cpp new file mode 100644 index 00000000000..d59effc53a3 --- /dev/null +++ b/mozilla/xpfc/shell/src/nsShellInstance.cpp @@ -0,0 +1,458 @@ +/* -*- 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. + */ +#define NS_IMPL_IDS 1 + +#include +#include "nscore.h" + +#include "nspr.h" +#include "net.h" +#include "plstr.h" + +#include "nsISupports.h" +#include "nsIShellInstance.h" +#include "nsShellInstance.h" +#include "nsITimer.h" + +#include "nsWidgetsCID.h" +#include "nsGfxCIID.h" +#include "nsxpfcCIID.h" +#include "nsParserCIID.h" +#include "nsIAppShell.h" +#include "nsIWebViewerContainer.h" + +#include "nsIPref.h" +#include "nsStreamManager.h" +#include "nsToolbarManager.h" + +#include "nsIBrowserWindow.h" +#include "nsIWebShell.h" +#include "nsIDocumentLoader.h" +#include "nsIThrobber.h" +#include "nsViewsCID.h" +#include "nsPluginsCID.h" +#include "nsIDeviceContext.h" + +#ifdef NS_WIN32 +#include "direct.h" +#include "windows.h" +#elif NS_UNIX +#include +#endif + + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); +static NS_DEFINE_IID(kCShellInstance, NS_XPFC_SHELL_INSTANCE_CID); +static NS_DEFINE_IID(kCStreamManager, NS_STREAM_MANAGER_CID); +static NS_DEFINE_IID(kIStreamManager, NS_ISTREAM_MANAGER_IID); +static NS_DEFINE_IID(kCToolbarManager, NS_TOOLBAR_MANAGER_CID); +static NS_DEFINE_IID(kIToolbarManager, NS_ITOOLBAR_MANAGER_IID); +static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); +static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); + +nsEventStatus PR_CALLBACK HandleEventApplication(nsGUIEvent *aEvent); +nsShellInstance * gShellInstance = nsnull; + +nsShellInstance::nsShellInstance() +{ + NS_INIT_REFCNT(); + mApplicationWindow = nsnull; + mPref = nsnull; + gShellInstance = this; + mStreamManager = nsnull; + mToolbarManager = nsnull; + mDeviceContext = nsnull; +} + +nsShellInstance::~nsShellInstance() +{ + NS_IF_RELEASE(mDeviceContext); + NS_IF_RELEASE(mApplicationWindow); + + if (mPref != nsnull) + mPref->Shutdown(); + + NS_IF_RELEASE(mPref); + NS_IF_RELEASE(mStreamManager); + NS_IF_RELEASE(mToolbarManager); +} + +NS_DEFINE_IID(kIShellInstanceIID, NS_IXPFC_SHELL_INSTANCE_IID); +NS_IMPL_ISUPPORTS(nsShellInstance,kIShellInstanceIID); + +nsresult nsShellInstance::Init() +{ + nsresult res = NS_OK; + + RegisterFactories() ; + + // Load preferences + res = nsRepository::CreateInstance(kPrefCID, NULL, kIPrefIID, + (void **) &mPref); + if (NS_OK != res) { + return res; + } + + mPref->Startup(nsnull); + + // Create a Stream Manager + res = nsRepository::CreateInstance(kCStreamManager, + NULL, + kIStreamManager, + (void **) &mStreamManager); + if (NS_OK != res) + return res; + + mStreamManager->Init(); + + + // Create a Toolbar Manager + res = nsRepository::CreateInstance(kCToolbarManager, + NULL, + kIToolbarManager, + (void **) &mToolbarManager); + if (NS_OK != res) + return res; + + mToolbarManager->Init(); + + return res; +} + +static nsITimer* gNetTimer; + +static void +PollNet(nsITimer *aTimer, void *aClosure) +{ + NET_PollSockets(); + NS_IF_RELEASE(gNetTimer); + if (NS_OK == NS_NewTimer(&gNetTimer)) { + gNetTimer->Init(PollNet, nsnull, 1000 / 50); + } +} + +nsresult nsShellInstance::Run() +{ + +#ifdef NS_WIN32 + MSG msg; + PollNet(0, 0); + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + NET_PollSockets(); + } + return ((nsresult)msg.wParam); +#elif NS_UNIX +#if 0 + extern XtAppContext app_context ; + + XtAppMainLoop(app_context) ; +#endif + extern XtAppContext app_context ; + extern Widget topLevel; + + XtRealizeWidget(topLevel); + + XEvent event; + for (;;) { + XtAppNextEvent(app_context, &event); + XtDispatchEvent(&event); + } + + return NS_OK; +#else + return NS_OK; +#endif +} + +void * nsShellInstance::GetNativeInstance() +{ + return mNativeInstance ; +} + +nsIPref * nsShellInstance::GetPreferences() +{ + return (mPref) ; +} + +nsIStreamManager * nsShellInstance::GetStreamManager() +{ + return (mStreamManager) ; +} + +nsIToolbarManager * nsShellInstance::GetToolbarManager() +{ + return (mToolbarManager) ; +} + +void nsShellInstance::SetNativeInstance(void * aNativeInstance) +{ + mNativeInstance = aNativeInstance; + return ; +} + +nsIApplicationShell * nsShellInstance::GetApplicationShell() +{ + return mApplicationShell ; +} + +void nsShellInstance::SetApplicationShell(nsIApplicationShell * aApplicationShell) +{ + mApplicationShell = aApplicationShell; + return ; +} + +// XXX We really need a standard way to enumerate +// a set of libraries and call their self +// registration routines... when that code is +// XP of course. +nsresult nsShellInstance::RegisterFactories() +{ + // hardcode names of dll's +#ifdef NS_WIN32 + #define GFXWIN_DLL "raptorgfxwin.dll" + #define WIDGET_DLL "raptorwidget.dll" + #define VIEW_DLL "raptorview.dll" + #define PARSER_DLL "raptorhtmlpars.dll" + #define PREF_DLL "xppref32.dll" + #define WEB_DLL "raptorweb.dll" + #define PLUGIN_DLL "raptorplugin.dll" +#else + #define GFXWIN_DLL "libgfxunix.so" + #define WIDGET_DLL "libwidgetunix.so" + #define VIEW_DLL "libraptorview.so" + #define PARSER_DLL "libraptorhtmlpars.so" + #define PREF_DLL "libpref.so" + #define WEB_DLL "libraptorweb.so" + #define PLUGIN_DLL "raptorplugin.so" +#endif + + + static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); + nsRepository::RegisterFactory(kIWidgetIID, WIDGET_DLL, PR_FALSE, PR_FALSE); + + // register graphics classes + static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID); + static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID); + static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID); + static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID); + static NS_DEFINE_IID(kCRegionIID, NS_REGION_CID); + + nsRepository::RegisterFactory(kCRenderingContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCDeviceContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCFontMetricsIID, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCImageIID, GFXWIN_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCRegionIID, GFXWIN_DLL, PR_FALSE, PR_FALSE); + + // register widget classes + static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID); + static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID); + static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID); + static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID); + static NS_DEFINE_IID(kCCheckButtonCID, NS_CHECKBUTTON_CID); + static NS_DEFINE_IID(kCComboBoxCID, NS_COMBOBOX_CID); + static NS_DEFINE_IID(kCListBoxCID, NS_LISTBOX_CID); + static NS_DEFINE_IID(kCRadioButtonCID, NS_RADIOBUTTON_CID); + static NS_DEFINE_IID(kCRadioGroupCID, NS_RADIOGROUP_CID); + static NS_DEFINE_IID(kCHorzScrollbarCID, NS_HORZSCROLLBAR_CID); + static NS_DEFINE_IID(kCVertScrollbarCID, NS_VERTSCROLLBAR_CID); + static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID); + static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID); + static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); + static NS_DEFINE_IID(kCParserNodeCID, NS_PARSER_NODE_IID); + static NS_DEFINE_IID(kCTabWidgetCID, NS_TABWIDGET_CID); + static NS_DEFINE_IID(kDocumentLoaderCID, NS_DOCUMENTLOADER_CID); + static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID); + static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); + static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID); + static NS_DEFINE_IID(kCViewManagerCID, NS_VIEW_MANAGER_CID); + static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID); + static NS_DEFINE_IID(kCScrollingViewCID, NS_SCROLLING_VIEW_CID); + + nsRepository::RegisterFactory(kCWindowCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCChildCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCCheckButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCComboBoxCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCFileWidgetCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCListBoxCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCRadioButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCRadioGroupCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCHorzScrollbarCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCVertScrollbarCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCTextAreaCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCTabWidgetCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCTextFieldCID, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCParserNodeCID, PARSER_DLL, PR_FALSE, PR_FALSE); + + nsRepository::RegisterFactory(kPrefCID, PREF_DLL, PR_FALSE, PR_FALSE); + + nsRepository::RegisterFactory(kDocumentLoaderCID, WEB_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kThrobberCID, WEB_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kWebShellCID, WEB_DLL, PR_FALSE, PR_FALSE); + + nsRepository::RegisterFactory(kCPluginHostCID, PLUGIN_DLL, PR_FALSE, PR_FALSE); + + nsRepository::RegisterFactory(kCViewManagerCID, VIEW_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCViewCID, VIEW_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCScrollingViewCID, VIEW_DLL, PR_FALSE, PR_FALSE); + + return NS_OK; +} + +nsIWidget * nsShellInstance::CreateApplicationWindow(nsIAppShell * aAppShell, + const nsRect &aRect) +{ + + nsRect windowRect ; + + if (aRect.IsEmpty()) { + windowRect.SetRect(100,100,320,480); + } else { + windowRect.SetRect(aRect.x, aRect.y, aRect.width, aRect.height); + } + + static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); + static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID); + + nsRepository::CreateInstance(kCWindowCID, + nsnull, + kIWidgetIID, + (void **)&(mApplicationWindow)); + + nsWidgetInitData initData ; + + initData.clipChildren = PR_TRUE; + + nsresult res = nsRepository::CreateInstance(kDeviceContextCID, + nsnull, + kDeviceContextIID, + (void **)&mDeviceContext); + + if (NS_OK == res) + mDeviceContext->Init(nsnull); + + mApplicationWindow->Create((nsIWidget*)nsnull, + aRect, + HandleEventApplication, + mDeviceContext, + aAppShell, + nsnull, + &initData); + + return (mApplicationWindow); +} + + +nsresult nsShellInstance::ShowApplicationWindow(PRBool show) +{ + mApplicationWindow->Show(show); + +#ifdef NS_UNIX + XtRealizeWidget((Widget)GetNativeInstance()); +#endif + + return NS_OK; +} + +nsresult nsShellInstance::ExitApplication() +{ + +#ifdef NS_WIN32 + PostQuitMessage(0); +#endif + return NS_OK; +} + +void * nsShellInstance::GetApplicationWindowNativeInstance() +{ + return (mApplicationWindow->GetNativeData(NS_NATIVE_WINDOW)); +} + +nsIWidget * nsShellInstance::GetApplicationWidget() +{ + return (mApplicationWindow); +} + +EVENT_CALLBACK nsShellInstance::GetShellEventCallback() +{ + return ((EVENT_CALLBACK)HandleEventApplication); +} + +nsresult nsShellInstance::LaunchApplication(nsString& aApplication) +{ + char * app = aApplication.ToNewCString(); + char *argv[2]; + + PRStatus status ; + + char path[1024]; + (void)getcwd(path, sizeof(path)); + (void)PL_strcat(path, "\\"); + (void)PL_strcat(path, app); + argv[0] = path; + argv[1] = nsnull; + + status = PR_CreateProcessDetached(argv[0], argv, nsnull, nsnull); + + if (status == PR_FAILURE) + return NS_OK; + + delete app; + + return NS_OK; +} + +nsEventStatus PR_CALLBACK HandleEventApplication(nsGUIEvent *aEvent) +{ + /* + * If this is a menu selection, generate a command object and + * dispatch it to the target object + */ + + if (aEvent->message == NS_MENU_SELECTED) + { + + nsIWebViewerContainer * viewer; + + nsresult res = gShellInstance->GetApplicationShell()->GetWebViewerContainer(&viewer); + + if (res == NS_OK) + { + nsMenuEvent * event = (nsMenuEvent *) aEvent; + + nsIMenuManager * menumgr = viewer->GetMenuManager(); + + nsIMenuItem * item = menumgr->MenuItemFromID(event->menuItem); + + item->SendCommand(); + + NS_RELEASE(viewer); + + return nsEventStatus_eIgnore; + + } + + } + + return (gShellInstance->GetApplicationShell()->HandleEvent(aEvent)); +} + diff --git a/mozilla/xpfc/shell/src/nsStreamManager.cpp b/mozilla/xpfc/shell/src/nsStreamManager.cpp new file mode 100644 index 00000000000..6a2a5e79aa2 --- /dev/null +++ b/mozilla/xpfc/shell/src/nsStreamManager.cpp @@ -0,0 +1,46 @@ +/* -*- 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. + */ + +#include +#include "nscore.h" + +#include "nsISupports.h" +#include "nsStreamManager.h" +#include "nsxpfcCIID.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); +static NS_DEFINE_IID(kCStreamManager, NS_STREAM_MANAGER_CID); + +nsStreamManager::nsStreamManager() +{ + NS_INIT_REFCNT(); +} + +nsStreamManager::~nsStreamManager() +{ +} + +NS_DEFINE_IID(kIStreamManagerIID, NS_ISTREAM_MANAGER_IID); +NS_IMPL_ISUPPORTS(nsStreamManager,kIStreamManagerIID); + +nsresult nsStreamManager::Init() +{ + return NS_OK; +} + diff --git a/mozilla/xpfc/shell/src/unix/Makefile b/mozilla/xpfc/shell/src/unix/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/shell/src/unix/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/shell/src/unix/config.mk b/mozilla/xpfc/shell/src/unix/config.mk new file mode 100644 index 00000000000..bbc0fe12dbf --- /dev/null +++ b/mozilla/xpfc/shell/src/unix/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = shell_s +LIBRARY_VERSION = + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/shell/src/unix/main.cpp b/mozilla/xpfc/shell/src/unix/main.cpp new file mode 100644 index 00000000000..86605abde0b --- /dev/null +++ b/mozilla/xpfc/shell/src/unix/main.cpp @@ -0,0 +1,161 @@ +/* -*- 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 Private 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 "nsRepository.h" +#include "nsShellInstance.h" +#include "nsApplicationManager.h" +#include "nsGfxCIID.h" +#include "nsxpfcCIID.h" +#include "nsIAppShell.h" +#include "nspr.h" + +#include "Xm/Xm.h" +#include "Xm/MainW.h" +#include "Xm/Frame.h" +#include "Xm/XmStrDefs.h" +#include "Xm/DrawingA.h" + +#define XPFC_DLL "libxpfc10.so" + +extern nsIID kIXPCOMApplicationShellCID ; + +static NS_DEFINE_IID(kIApplicationShellIID, NS_IAPPLICATIONSHELL_IID); +static NS_DEFINE_IID(kCApplicationShellIID, NS_IAPPLICATIONSHELL_CID); + +static NS_DEFINE_IID(kIShellInstanceIID, NS_IXPFC_SHELL_INSTANCE_IID); +static NS_DEFINE_IID(kCShellInstanceCID, NS_XPFC_SHELL_INSTANCE_CID); +static NS_DEFINE_IID(kCMenuBarCID, NS_MENUBAR_CID); +static NS_DEFINE_IID(kCMenuContainerCID, NS_MENUCONTAINER_CID); +static NS_DEFINE_IID(kCMenuItemCID, NS_MENUITEM_CID); +static NS_DEFINE_IID(kCMenuManagerCID, NS_MENU_MANAGER_CID); +static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID); +static NS_DEFINE_IID(kCXPFCToolbarCID, NS_XPFC_TOOLBAR_CID); +static NS_DEFINE_IID(kCXPFCDialogCID, NS_XPFC_DIALOG_CID); +static NS_DEFINE_IID(kCXPFCButtonCID, NS_XPFC_BUTTON_CID); +static NS_DEFINE_IID(kCXPFCTextWidgetCID, NS_XPFC_TEXTWIDGET_CID); +static NS_DEFINE_IID(kCXPFCTabWidgetCID, NS_XPFC_TABWIDGET_CID); +static NS_DEFINE_IID(kCToolbarManagerCID, NS_TOOLBAR_MANAGER_CID); +static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); +static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID); +static NS_DEFINE_IID(kCstackCID, NS_STACK_CID); +static NS_DEFINE_IID(kCStreamManagerCID, NS_STREAM_MANAGER_CID); + +XtAppContext app_context ; +Widget topLevel; +extern XtAppContext gAppContext ; + +void main(int argc, char **argv) +{ + nsresult result = NS_OK ; + + nsIShellInstance * pShellInstance ; + nsIApplicationShell * pApplicationShell ; + + XtSetLanguageProc(NULL, NULL, NULL); + + topLevel = XtVaAppInitialize(&app_context, "Shell", NULL, 0, &argc, argv, NULL, NULL); + + gAppContext = app_context; + + PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); + PR_STDIO_INIT(); + + // Let get a ShellInstance for this Application instance + nsRepository::RegisterFactory(kCShellInstanceCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCMenuBarCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCMenuContainerCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCMenuItemCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCMenuManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCToolbarCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCDialogCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCButtonCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCTextWidgetCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCTabWidgetCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCToolbarManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCStreamManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCVectorCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCVectorIteratorCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCstackCID, XPFC_DLL, PR_FALSE, PR_FALSE); + + result = nsRepository::CreateInstance(kCShellInstanceCID, + NULL, + kIShellInstanceIID, + (void **) &pShellInstance) ; + + if (result != NS_OK) + return result ; + + // Let's instantiate the Application's Shell + NS_RegisterApplicationShellFactory() ; + + result = nsRepository::CreateInstance(kIXPCOMApplicationShellCID, + NULL, + kIXPCOMApplicationShellCID, + (void **) &pApplicationShell) ; + + if (result != NS_OK) + return result ; + + + // Let the the State know who it's Application Instance is + pShellInstance->SetNativeInstance((nsNativeApplicationInstance) topLevel); + pShellInstance->SetApplicationShell(pApplicationShell); + + // Tell the application manager to store away the association so the + // Application can look up its State + nsApplicationManager::SetShellAssociation(pApplicationShell, pShellInstance); + + // Initialize the system + + pShellInstance->Init(); + pApplicationShell->Init(); + + // Now, let actually start dispatching events. + nsIAppShell * app_shell = nsnull; + + result = pApplicationShell->QueryInterface(kIAppShellIID,(void**)&app_shell); + + if (result == NS_OK) + { + result = app_shell->Run(); + NS_RELEASE(app_shell); + } + + + // We're done, clean up + nsApplicationManager::DeleteShellAssociation(pApplicationShell, pShellInstance); + PR_Cleanup(); + + // book out of here + return ; +} + + + + + + + + + + + + + + + diff --git a/mozilla/xpfc/shell/src/unix/manifest.mn b/mozilla/xpfc/shell/src/unix/manifest.mn new file mode 100644 index 00000000000..9d5f9b9f89a --- /dev/null +++ b/mozilla/xpfc/shell/src/unix/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + main.cpp \ + $(NULL) + +REQUIRES = xpcom raptor + diff --git a/mozilla/xpfc/shell/src/windows/Makefile b/mozilla/xpfc/shell/src/windows/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/shell/src/windows/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/shell/src/windows/config.mk b/mozilla/xpfc/shell/src/windows/config.mk new file mode 100644 index 00000000000..97fe9f1fc76 --- /dev/null +++ b/mozilla/xpfc/shell/src/windows/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = shell +LIBRARY_VERSION = + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/shell/src/windows/manifest.mn b/mozilla/xpfc/shell/src/windows/manifest.mn new file mode 100644 index 00000000000..44d14682646 --- /dev/null +++ b/mozilla/xpfc/shell/src/windows/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + winmain.cpp \ + $(NULL) + +REQUIRES = xpcom raptor + diff --git a/mozilla/xpfc/shell/src/windows/winmain.cpp b/mozilla/xpfc/shell/src/windows/winmain.cpp new file mode 100644 index 00000000000..d40f1aafa80 --- /dev/null +++ b/mozilla/xpfc/shell/src/windows/winmain.cpp @@ -0,0 +1,143 @@ +/* -*- 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 Private 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. + */ + +#ifdef WIN32_LEAN_AND_MEAN +#undef WIN32_LEAN_AND_MEAN +#endif + +#include +#include "nsRepository.h" +#include "nsShellInstance.h" +#include "nsApplicationManager.h" +#include "nsxpfcCIID.h" +#include "nsIAppShell.h" +#include "nspr.h" + +#define XPFC_DLL "xpfc10.dll" + +extern nsIID kIXPCOMApplicationShellCID ; + +static NS_DEFINE_IID(kIApplicationShellIID, NS_IAPPLICATIONSHELL_IID); +static NS_DEFINE_IID(kCApplicationShellIID, NS_IAPPLICATIONSHELL_CID); + +static NS_DEFINE_IID(kIShellInstanceIID, NS_IXPFC_SHELL_INSTANCE_IID); +static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID); +static NS_DEFINE_IID(kCShellInstanceCID, NS_XPFC_SHELL_INSTANCE_CID); +static NS_DEFINE_IID(kCMenuBarCID, NS_MENUBAR_CID); +static NS_DEFINE_IID(kCMenuContainerCID, NS_MENUCONTAINER_CID); +static NS_DEFINE_IID(kCMenuItemCID, NS_MENUITEM_CID); + +static NS_DEFINE_IID(kCMenuManagerCID, NS_MENU_MANAGER_CID); + +static NS_DEFINE_IID(kCXPFCToolbarCID, NS_XPFC_TOOLBAR_CID); +static NS_DEFINE_IID(kCXPFCDialogCID, NS_XPFC_DIALOG_CID); +static NS_DEFINE_IID(kCXPFCButtonCID, NS_XPFC_BUTTON_CID); +static NS_DEFINE_IID(kCXPFCTextWidgetCID, NS_XPFC_TEXTWIDGET_CID); +static NS_DEFINE_IID(kCXPFCTabWidgetCID, NS_XPFC_TABWIDGET_CID); + +static NS_DEFINE_IID(kCToolbarManagerCID, NS_TOOLBAR_MANAGER_CID); +static NS_DEFINE_IID(kCStreamManagerCID, NS_STREAM_MANAGER_CID); +static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); +static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID); +static NS_DEFINE_IID(kCstackCID, NS_STACK_CID); + +int PASCAL WinMain(HANDLE instance, HANDLE prevInstance, LPSTR cmdParam, int nCmdShow) +{ + nsresult result = NS_OK ; + + nsIShellInstance * pShellInstance ; + nsIApplicationShell * pApplicationShell ; + + PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); + PR_STDIO_INIT(); + + // Let get a ShellInstance for this Application instance + nsRepository::RegisterFactory(kCShellInstanceCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCMenuBarCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCMenuContainerCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCMenuManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCMenuItemCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCToolbarCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCDialogCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCButtonCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCTextWidgetCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCXPFCTabWidgetCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCToolbarManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCStreamManagerCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCVectorCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCVectorIteratorCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCstackCID, XPFC_DLL, PR_FALSE, PR_FALSE); + + result = nsRepository::CreateInstance(kCShellInstanceCID, + NULL, + kIShellInstanceIID, + (void **) &pShellInstance) ; + + if (result != NS_OK) + return result ; + + // Let's instantiate the Application's Shell + NS_RegisterApplicationShellFactory() ; + + result = nsRepository::CreateInstance(kIXPCOMApplicationShellCID, + NULL, + kIXPCOMApplicationShellCID, + (void **) &pApplicationShell) ; + + if (result != NS_OK) + return result ; + + // Let the the State know who it's Application Instance is + pShellInstance->SetNativeInstance((nsNativeApplicationInstance) instance); + pShellInstance->SetApplicationShell(pApplicationShell); + + // Tell the application manager to store away the association so the + // Application can look up its State + nsApplicationManager::SetShellAssociation(pApplicationShell, pShellInstance); + + // Initialize the system + pShellInstance->Init(); + pApplicationShell->Init(); + + // Now, let actually start dispatching events. + nsIAppShell * app_shell = nsnull; + + result = pApplicationShell->QueryInterface(kIAppShellIID,(void**)&app_shell); + + if (result == NS_OK) + { + result = app_shell->Run(); + NS_RELEASE(app_shell); + } + + // We're done, clean up + nsApplicationManager::DeleteShellAssociation(pApplicationShell, pShellInstance); + + NS_RELEASE(pApplicationShell); + NS_RELEASE(pShellInstance); + + PR_Cleanup(); + + // book out of here + return result; +} + +void main(int argc, char **argv) +{ + WinMain(GetModuleHandle(NULL), NULL, 0, SW_SHOW); +} diff --git a/mozilla/xpfc/shell/tests/apptest/Makefile b/mozilla/xpfc/shell/tests/apptest/Makefile new file mode 100644 index 00000000000..cdbe43be492 --- /dev/null +++ b/mozilla/xpfc/shell/tests/apptest/Makefile @@ -0,0 +1,121 @@ +#!gmake +# +# 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. + +DEPTH=../../../../../.. + +include $(DEPTH)/config/config.mk + +CPPSRCS = \ + nsAppTest.cpp \ + $(NULL) + +INCLUDES+= -I$(PUBLIC)/raptor -I$(PUBLIC)/xpcom -I$(PUBLIC)/xpfc + +DIRS = + +OBJS = $(CPPSRCS:.cpp=.o) + +EX_LIBS = \ + $(DIST)/lib/libshell_s.a \ + $(DIST)/lib/libshell10.a \ + $(DIST)/bin/libwidgetunix.so \ + $(DIST)/bin/libraptorgfx.so \ + $(DIST)/bin/libgfxunix.so \ + $(DIST)/bin/libraptorbase.so \ + $(DIST)/bin/libgmbaseunix.so \ + $(DIST)/bin/libxpcom.so \ + $(DIST)/bin/libreg.so \ + $(DIST)/bin/libnspr21.so \ + $(DIST)/bin/libplc21.so \ + $(DIST)/bin/libplds21.so \ + $(DIST)/bin/libnspr21.so \ + $(DIST)/bin/libraptorbase.so \ + $(DIST)/bin/libpng.so \ + $(DIST)/bin/libpref.so \ + $(DIST)/bin/libraptorbase.so \ + $(DIST)/bin/libwidgetunix.so \ + $(DIST)/bin/libraptorgfx.so \ + $(DIST)/bin/libgfxunix.so \ + $(DIST)/bin/libraptorhtml.so \ + $(DIST)/bin/libgmbaseunix.so \ + $(DIST)/bin/libraptorhtmlpars.so \ + $(DIST)/bin/libraptorview.so \ + $(DIST)/bin/libreg.so \ + $(DIST)/bin/libabouturl.so \ + $(DIST)/bin/libfileurl.so \ + $(DIST)/bin/libftpurl.so \ + $(DIST)/bin/libgophurl.so \ + $(DIST)/bin/libhttpurl.so \ + $(DIST)/bin/libimg.so \ + $(DIST)/bin/libjpeg.so \ + $(DIST)/bin/libjs.so \ + $(DIST)/bin/libjsdom.so \ + $(DIST)/bin/libjsj.so \ + $(DIST)/bin/libmimetype.so \ + $(DIST)/bin/libmsgc21.so \ + $(DIST)/bin/libnetcache.so \ + $(DIST)/bin/libnetcnvts.so \ + $(DIST)/bin/libnetlib.so \ + $(DIST)/bin/libnetutil.so \ + $(DIST)/bin/libnetwork.so \ + $(DIST)/bin/libnspr21.so \ + $(DIST)/bin/libplc21.so \ + $(DIST)/bin/libplds21.so \ + $(DIST)/bin/libraptorwebwidget.so \ + $(DIST)/bin/libreg.so \ + $(DIST)/bin/libremoturl.so \ + $(DIST)/bin/libsecfree.so \ + $(DIST)/bin/libstubnj.so \ + $(DIST)/bin/libstubsj.so \ + $(DIST)/bin/libtestdynamic.so \ + $(DIST)/bin/libutil.so \ + $(DIST)/bin/libxp.so \ + $(DIST)/bin/libxpcom.so \ + $(DIST)/bin/libzlib.so \ + $(DIST)/bin/libutil.so \ + $(DIST)/bin/libxp.so \ + $(DIST)/bin/libxpcom.so \ + $(DIST)/bin/libzlib.so \ + $(DIST)/bin/libraptorplugin.so \ + $(NULL) + + +PROGS = $(addprefix $(OBJDIR)/, $(CPPSRCS:.cpp=)) + +TARGETS = $(PROGS) + +include $(DEPTH)/config/rules.mk + +$(OBJDIR)/%.o: %.cpp + @$(MAKE_OBJDIR) + $(CCC) -o $@ $(CFLAGS) -c $*.cpp + +$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(EX_LIBS) + @$(MAKE_OBJDIR) +ifeq ($(OS_ARCH),Linux) + $(CCC) -rdynamic -o $@ $@.o $(LDFLAGS) $(EX_LIBS) $(OS_LIBS) -L/usr/X11R6/lib -lXm -lXt -lX11 -lXp -lXext +else + $(CCC) -o $@ $@.o $(LDFLAGS) $(EX_LIBS) $(OS_LIBS) -lXm -lXt -lX11 +endif + +export:: + +install:: $(TARGETS) + $(INSTALL) $(PROGS) $(DIST)/bin + + + diff --git a/mozilla/xpfc/shell/tests/apptest/apptest.rc b/mozilla/xpfc/shell/tests/apptest/apptest.rc new file mode 100644 index 00000000000..650a8f5a4e4 --- /dev/null +++ b/mozilla/xpfc/shell/tests/apptest/apptest.rc @@ -0,0 +1,28 @@ +/* -*- 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 "resources.h" + +APPTEST MENU DISCARDABLE +{ + POPUP "File" + { + MENUITEM "Open...", TIMER_OPEN + MENUITEM "Exit", TIMER_EXIT + } +} diff --git a/mozilla/xpfc/shell/tests/apptest/makefile.win b/mozilla/xpfc/shell/tests/apptest/makefile.win new file mode 100644 index 00000000000..d0ab6c7b6ec --- /dev/null +++ b/mozilla/xpfc/shell/tests/apptest/makefile.win @@ -0,0 +1,51 @@ +# +# 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. + +DEPTH=..\..\..\..\..\.. + +MAKE_OBJ_TYPE = EXE +PROGRAM = .\$(OBJDIR)\nsAppTest.exe +RESFILE = apptest.res +MAPFILE = apptest.map + +LINCS=-I$(XPDIST)\public\raptor -I$(XPDIST)\public\xpfc -I$(XPDIST)\public\xpcom -I..\..\src + +LLFLAGS = $(LLFLAGS) /SUBSYSTEM:CONSOLE + +OBJS = \ + .\$(OBJDIR)\nsAppTest.obj \ + $(NULL) + +LLIBS= \ + $(DIST)\lib\raptorbase.lib \ + $(DIST)\lib\raptorgfxwin.lib \ + $(DIST)\lib\raptorweb.lib \ + $(DIST)\lib\xpfc10.lib \ + $(DIST)\lib\shell_s.lib \ + $(DIST)\lib\xpcom32.lib \ + $(LIBNSPR) \ + $(DIST)\lib\libplc21.lib \ + $(DIST)\lib\util.lib \ + comdlg32.lib + +include <$(DEPTH)\config\rules.mak> + +install:: $(PROGRAM) + $(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin + +clobber:: + rm -f $(DIST)\bin\nsAppTest.exe + diff --git a/mozilla/xpfc/shell/tests/apptest/nsAppTest.cpp b/mozilla/xpfc/shell/tests/apptest/nsAppTest.cpp new file mode 100644 index 00000000000..acd035d4789 --- /dev/null +++ b/mozilla/xpfc/shell/tests/apptest/nsAppTest.cpp @@ -0,0 +1,268 @@ +/* -*- 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. + */ +#include "nscore.h" +#include "nsAppTest.h" +#include "nsApplicationManager.h" + +#include "nsString.h" +#include "nsFont.h" + +// TODO: Put this in nsIShellInstance.... + +#ifdef NS_UNIX +#include "Xm/Xm.h" +#include "Xm/MainW.h" +#include "Xm/Frame.h" +#include "Xm/XmStrDefs.h" +#include "Xm/DrawingA.h" + +extern XtAppContext app_context; +extern Widget topLevel; +#endif + +// All Applications must specify this *special* application CID +// to their own unique IID. +nsIID kIXPCOMApplicationShellCID = NS_IAPPTEST_IID ; + +// All Application Must implement this function +nsresult NS_RegisterApplicationShellFactory() +{ + nsresult res = nsRepository::RegisterFactory(kIXPCOMApplicationShellCID, + new nsAppTestFactory(), + PR_FALSE) ; + + return res; +} + +/* + * nsAppTest Definition + */ + +nsAppTest::nsAppTest() +{ + NS_INIT_REFCNT(); +} + +nsAppTest::~nsAppTest() +{ +} + +static NS_DEFINE_IID(kIAppTestIID, NS_IAPPTEST_IID); +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID); + + +nsresult nsAppTest::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + + if(aIID.Equals(kISupportsIID)) { //do IUnknown... + *aInstancePtr = (nsISupports*)(nsIApplicationShell*)(this); + } + else if(aIID.Equals(kIXPCOMApplicationShellCID)) { //do nsIContentSink base class... + *aInstancePtr = (nsAppTest*)(this); + } + else if(aIID.Equals(kIAppTestIID)) { //do nsIContentSink base class... + *aInstancePtr = (nsAppTest*)(this); + } + else if(aIID.Equals(kIAppShellIID)) { //do nsIContentSink base class... + *aInstancePtr = (nsIAppShell*)(this); + } + else { + *aInstancePtr=0; + return NS_NOINTERFACE; + } + ((nsISupports*) *aInstancePtr)->AddRef(); + return NS_OK; +} + +NS_IMPL_ADDREF(nsAppTest) +NS_IMPL_RELEASE(nsAppTest) + +nsresult nsAppTest::Init() +{ + + + nsresult res = nsApplicationManager::GetShellInstance(this, &mShellInstance) ; + + if (NS_OK != res) + return res ; + + nsRect aRect(100,100,540, 380) ; + + nsIAppShell * appshell ; + + res = QueryInterface(kIAppShellIID,(void**)&appshell); + + if (NS_OK != res) + return res ; + + + mShellInstance->CreateApplicationWindow(appshell,aRect); + mShellInstance->ShowApplicationWindow(PR_TRUE) ; + + return res ; + +} + +void* nsAppTest::GetNativeData(PRUint32 aDataType) +{ +#ifdef XP_UNIX + if (aDataType == NS_NATIVE_SHELL) + return topLevel; + + return nsnull; +#else + return (mShellInstance->GetApplicationWidget()); +#endif + +} + +void nsAppTest::Create(int* argc, char ** argv) +{ + return; +} +void nsAppTest::Exit() +{ + return; +} +void nsAppTest::SetDispatchListener(nsDispatchListener* aDispatchListener) +{ + return ; +} + +nsresult nsAppTest::Run() +{ + return (mShellInstance->Run()); +} + +/* + * nsAppTestFactory Definition + */ + +nsAppTestFactory::nsAppTestFactory() +{ + NS_INIT_REFCNT(); +} + +nsAppTestFactory::~nsAppTestFactory() +{ +} + +NS_DEFINE_IID(kIAppTestFactoryIID, NS_IFACTORY_IID); +NS_IMPL_ISUPPORTS(nsAppTestFactory,kIAppTestFactoryIID); + + +nsresult nsAppTestFactory::CreateInstance(nsISupports * aOuter, + const nsIID &aIID, + void ** aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL ; + + nsISupports * inst = (nsISupports *)(nsIApplicationShell*)new nsAppTest() ; + + if (inst == NULL) { + return NS_ERROR_OUT_OF_MEMORY; + } + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) { + delete inst ; + } + + return res; + +} + +nsresult nsAppTestFactory::LockFactory(PRBool aLock) +{ + return NS_OK; +} + + +nsEventStatus nsAppTest::HandleEvent(nsGUIEvent *aEvent) +{ + nsEventStatus result = nsEventStatus_eConsumeNoDefault; + + switch(aEvent->message) { + + case NS_CREATE: + { + return nsEventStatus_eConsumeNoDefault; + } + break ; + + case NS_DESTROY: + { + mShellInstance->ExitApplication() ; + return nsEventStatus_eConsumeNoDefault; + } + break ; + + case NS_PAINT: + { + nsRect aRect(0,0,540, 380) ; + // paint the background + nsString aString("Hello World!\n"); + nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext; + nsDrawingSurface ds; + + ds = rndctx->CreateDrawingSurface(&aRect); + rndctx->SelectOffScreenDrawingSurface(ds); + + nsFont font("serif", NS_FONT_STYLE_NORMAL, + NS_FONT_VARIANT_SMALL_CAPS, + NS_FONT_WEIGHT_NORMAL, + 0, + 12); + + rndctx->SetFont(font); + + + + rndctx->SetColor(NS_RGB(0, 0, 255)); + rndctx->FillRect(aRect); + + rndctx->SetColor(NS_RGB(255, 0, 0)); + rndctx->DrawString(aString, 50, 50, 100); + + rndctx->CopyOffScreenBits(aRect); + rndctx->DestroyDrawingSurface(ds); + return nsEventStatus_eConsumeNoDefault; + } + break; + + } + + return nsEventStatus_eIgnore; +} + + + + +nsresult nsAppTest::GetWebViewerContainer(nsIWebViewerContainer ** aWebViewerContainer) +{ + return NS_OK; +} diff --git a/mozilla/xpfc/shell/tests/apptest/nsAppTest.h b/mozilla/xpfc/shell/tests/apptest/nsAppTest.h new file mode 100644 index 00000000000..764973d324f --- /dev/null +++ b/mozilla/xpfc/shell/tests/apptest/nsAppTest.h @@ -0,0 +1,84 @@ +/* -*- 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 _nsAppTest_h__ +#define _nsAppTest_h__ + +#include +#include "nsIApplicationShell.h" +#include "nsIShellInstance.h" +#include "nsIFactory.h" +#include "nsRepository.h" +#include "nsShellInstance.h" +#include "nsIAppShell.h" + +#define NS_IAPPTEST_IID \ + { 0x5040bd10, 0xdec5, 0x11d1, \ + {0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +/* + * AppTest Class Declaration + */ + +class nsAppTest : public nsIApplicationShell, + public nsIAppShell +{ +public: + nsAppTest(); + ~nsAppTest(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + virtual nsresult Run(); + + virtual void Create(int* argc, char ** argv) ; + virtual void SetDispatchListener(nsDispatchListener* aDispatchListener) ; + virtual void Exit(); + virtual void* GetNativeData(PRUint32 aDataType) ; + NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent) ; + NS_IMETHOD GetWebViewerContainer(nsIWebViewerContainer ** aWebViewerContainer) ; + +public: + nsIShellInstance * mShellInstance; + +}; + +/* + * AppTestFactory Class Declaration + */ + +class nsAppTestFactory : public nsIFactory { + +public: + nsAppTestFactory(); + ~nsAppTestFactory(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD CreateInstance(nsISupports * aOuter, + const nsIID &aIID, + void ** aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + + +}; + + +#endif diff --git a/mozilla/xpfc/shell/tests/apptest/resources.h b/mozilla/xpfc/shell/tests/apptest/resources.h new file mode 100644 index 00000000000..3358b700284 --- /dev/null +++ b/mozilla/xpfc/shell/tests/apptest/resources.h @@ -0,0 +1,25 @@ +/* -*- 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 resources_h___ +#define resources_h___ + +#define TIMER_OPEN 40010 +#define TIMER_EXIT 40011 + +#endif /* resources_h___ */ diff --git a/mozilla/xpfc/toolkit/Makefile b/mozilla/xpfc/toolkit/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/toolkit/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/toolkit/inc/Makefile b/mozilla/xpfc/toolkit/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/toolkit/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/toolkit/inc/manifest.mn b/mozilla/xpfc/toolkit/inc/manifest.mn new file mode 100644 index 00000000000..38e5bad9fe8 --- /dev/null +++ b/mozilla/xpfc/toolkit/inc/manifest.mn @@ -0,0 +1,21 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + nsXPFCToolkit.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/toolkit/inc/nsXPFCToolkit.h b/mozilla/xpfc/toolkit/inc/nsXPFCToolkit.h new file mode 100644 index 00000000000..a4c391162da --- /dev/null +++ b/mozilla/xpfc/toolkit/inc/nsXPFCToolkit.h @@ -0,0 +1,61 @@ +/* -*- 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 nsXPFCToolkit_h___ +#define nsXPFCToolkit_h___ + +#include "nsxpfc.h" +#include "nsIXPFCToolkit.h" +#include "nsIApplicationShell.h" +#include "nsIXPFCObserverManager.h" +#include "nsIXPFCCanvasManager.h" + +CLASS_EXPORT_XPFC nsXPFCToolkit : public nsIXPFCToolkit +{ +public: + nsXPFCToolkit(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(nsIApplicationShell * aApplicationShell) ; + + NS_IMETHOD SetObserverManager(nsIXPFCObserverManager * aObserverManager); + NS_IMETHOD_(nsIXPFCObserverManager *) GetObserverManager(); + + NS_IMETHOD SetCanvasManager(nsIXPFCCanvasManager * aCanvasManager); + NS_IMETHOD_(nsIXPFCCanvasManager *) GetCanvasManager(); + + NS_IMETHOD GetRootCanvas(nsIXPFCCanvas ** aCanvas); + NS_IMETHOD_(EVENT_CALLBACK) GetShellEventCallback() ; + +protected: + ~nsXPFCToolkit(); + +private: + nsIApplicationShell * mApplicationShell; + nsIXPFCObserverManager * mObserverManager; + nsIXPFCCanvasManager * mCanvasManager; + +}; + +// XXX: Need a SessionManager to manage various toolkits across +// different applications. For now, this is a convenient +// way to access the global application shell +extern NS_XPFC nsXPFCToolkit * gXPFCToolkit; + +#endif /* nsXPFCToolkit_h___ */ diff --git a/mozilla/xpfc/toolkit/manifest.mn b/mozilla/xpfc/toolkit/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/toolkit/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/toolkit/public/Makefile b/mozilla/xpfc/toolkit/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/toolkit/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/toolkit/public/manifest.mn b/mozilla/xpfc/toolkit/public/manifest.mn new file mode 100644 index 00000000000..0f708350814 --- /dev/null +++ b/mozilla/xpfc/toolkit/public/manifest.mn @@ -0,0 +1,22 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIXPFCToolkit.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/toolkit/public/nsIXPFCToolkit.h b/mozilla/xpfc/toolkit/public/nsIXPFCToolkit.h new file mode 100644 index 00000000000..1eb33c3d710 --- /dev/null +++ b/mozilla/xpfc/toolkit/public/nsIXPFCToolkit.h @@ -0,0 +1,55 @@ +/* -*- 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 nsIXPFCToolkit_h___ +#define nsIXPFCToolkit_h___ + +#include "nsISupports.h" +#include "nsIXPFCObserverManager.h" +#include "nsIXPFCCanvasManager.h" +#include "nsIXPFCCanvas.h" + + +class nsIApplicationShell; + +//d666a630-32e1-11d2-9248-00805f8a7ab6 +#define NS_IXPFC_TOOLKIT_IID \ +{ 0xd666a630, 0x32e1, 0x11d2, \ +{ 0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsIXPFCToolkit : public nsISupports +{ + +public: + + NS_IMETHOD Init(nsIApplicationShell * aApplicationShell) = 0; + + NS_IMETHOD SetObserverManager(nsIXPFCObserverManager * aObserverManager) = 0; + NS_IMETHOD_(nsIXPFCObserverManager *) GetObserverManager() = 0; + + NS_IMETHOD SetCanvasManager(nsIXPFCCanvasManager * aCanvasManager) = 0; + NS_IMETHOD_(nsIXPFCCanvasManager *) GetCanvasManager() = 0; + + NS_IMETHOD GetRootCanvas(nsIXPFCCanvas ** aCanvas) = 0; + NS_IMETHOD_(EVENT_CALLBACK) GetShellEventCallback() = 0; + +}; + +#endif /* nsIXPFCToolkit_h___ */ + + diff --git a/mozilla/xpfc/toolkit/src/Makefile b/mozilla/xpfc/toolkit/src/Makefile new file mode 100644 index 00000000000..60df328e33a --- /dev/null +++ b/mozilla/xpfc/toolkit/src/Makefile @@ -0,0 +1,54 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/toolkit/src/config.mk b/mozilla/xpfc/toolkit/src/config.mk new file mode 100644 index 00000000000..e7f7d7285bc --- /dev/null +++ b/mozilla/xpfc/toolkit/src/config.mk @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC +INCLUDES +=-I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = toolkit +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) + diff --git a/mozilla/xpfc/toolkit/src/manifest.mn b/mozilla/xpfc/toolkit/src/manifest.mn new file mode 100644 index 00000000000..e55df327dcf --- /dev/null +++ b/mozilla/xpfc/toolkit/src/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsXPFCToolkit.cpp \ + $(NULL) + +REQUIRES = shell xpcom raptor netlib + diff --git a/mozilla/xpfc/toolkit/src/nsXPFCToolkit.cpp b/mozilla/xpfc/toolkit/src/nsXPFCToolkit.cpp new file mode 100644 index 00000000000..2f7e82d4bf8 --- /dev/null +++ b/mozilla/xpfc/toolkit/src/nsXPFCToolkit.cpp @@ -0,0 +1,106 @@ +/* -*- 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. + */ + +#include "nsXPFCToolkit.h" +#include "nsxpfcCIID.h" +#include "nsXPFCCanvasManager.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kXPFCToolkitIID, NS_IXPFC_TOOLKIT_IID); + +NS_XPFC nsXPFCToolkit * gXPFCToolkit = nsnull; +nsEventStatus PR_CALLBACK HandleEventApplication(nsGUIEvent *aEvent); + +nsXPFCToolkit :: nsXPFCToolkit() +{ + NS_INIT_REFCNT(); + + if (gXPFCToolkit == nsnull) + gXPFCToolkit = (nsXPFCToolkit *)this; + + mApplicationShell = nsnull; + mObserverManager = nsnull; + mCanvasManager = nsnull; + +} + +nsXPFCToolkit :: ~nsXPFCToolkit() +{ + NS_RELEASE(mCanvasManager); + gXPFCToolkit = nsnull; +} + +NS_IMPL_ADDREF(nsXPFCToolkit) +NS_IMPL_RELEASE(nsXPFCToolkit) +NS_IMPL_QUERY_INTERFACE(nsXPFCToolkit, kXPFCToolkitIID) + +nsresult nsXPFCToolkit::Init(nsIApplicationShell * aApplicationShell) +{ + mApplicationShell = aApplicationShell; + + /* + * Create the canvas manager + */ + + static NS_DEFINE_IID(kCXPFCCanvasManagerCID, NS_XPFC_CANVASMANAGER_CID); + static NS_DEFINE_IID(kCXPFCCanvasManagerIID, NS_IXPFC_CANVAS_MANAGER_IID); + + nsresult res = nsRepository::CreateInstance(kCXPFCCanvasManagerCID, + nsnull, + kCXPFCCanvasManagerIID, + (void **)&mCanvasManager); + + if (NS_OK != res) + return res ; + + mCanvasManager->Init(); + + return NS_OK; +} + +nsresult nsXPFCToolkit::SetObserverManager(nsIXPFCObserverManager * aObserverManager) +{ + mObserverManager = aObserverManager; + return NS_OK; +} + +nsIXPFCObserverManager * nsXPFCToolkit::GetObserverManager() +{ + return (mObserverManager); +} + +nsresult nsXPFCToolkit::SetCanvasManager(nsIXPFCCanvasManager * aCanvasManager) +{ + mCanvasManager = aCanvasManager; + return NS_OK; +} + +nsIXPFCCanvasManager * nsXPFCToolkit::GetCanvasManager() +{ + return (mCanvasManager); +} + +nsresult nsXPFCToolkit::GetRootCanvas(nsIXPFCCanvas ** aCanvas) +{ + return (mCanvasManager->GetRootCanvas(aCanvas)); +} + +EVENT_CALLBACK nsXPFCToolkit::GetShellEventCallback() +{ + return ((EVENT_CALLBACK)HandleEventApplication); +} diff --git a/mozilla/xpfc/util/Makefile b/mozilla/xpfc/util/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/util/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/util/inc/Makefile b/mozilla/xpfc/util/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/util/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/util/inc/manifest.mn b/mozilla/xpfc/util/inc/manifest.mn new file mode 100644 index 00000000000..60228bad24e --- /dev/null +++ b/mozilla/xpfc/util/inc/manifest.mn @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + nsVectorIterator.h \ + nsVector.h \ + nsStack.h \ + nsxpfcutil.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/util/inc/nsStack.h b/mozilla/xpfc/util/inc/nsStack.h new file mode 100644 index 00000000000..60e6a858f46 --- /dev/null +++ b/mozilla/xpfc/util/inc/nsStack.h @@ -0,0 +1,49 @@ +/* -*- 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 nsStack_h___ +#define nsStack_h___ + +#include "nsIStack.h" + +#include "nsVoidArray.h" + +class nsStack : public nsIStack +{ + +public: + nsStack(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + + NS_IMETHOD_(PRBool) Empty(); + NS_IMETHOD Push(nsComponent aComponent); + NS_IMETHOD_(nsComponent) Pop(); + NS_IMETHOD_(nsComponent) Top(); + +protected: + ~nsStack(); + +private: + nsVoidArray * mVoidArray ; + +}; + +#endif /* nsStack_h___ */ diff --git a/mozilla/xpfc/util/inc/nsVector.h b/mozilla/xpfc/util/inc/nsVector.h new file mode 100644 index 00000000000..68579c14f57 --- /dev/null +++ b/mozilla/xpfc/util/inc/nsVector.h @@ -0,0 +1,59 @@ +/* -*- 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 nsVector_h___ +#define nsVector_h___ + +#include "nsIVector.h" + +#include "nsVoidArray.h" + +class nsVector : public nsIVector +{ + +public: + nsVector(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init() ; + + NS_IMETHOD_(PRUint32) Count() ; + NS_IMETHOD_(PRBool) Empty() ; + NS_IMETHOD_(PRBool) Contains(nsComponent aComponent) ; + NS_IMETHOD_(PRUint32) IndexOf(nsComponent aComponent) ; + NS_IMETHOD_(nsComponent) ElementAt(PRUint32 aIndex) ; + NS_IMETHOD_(PRInt32) InsertBinary(nsComponent aComponent, nsVectorCompareProc aCompFn, PRBool bAllowDups); + + NS_IMETHOD Insert(PRUint32 aIndex, nsComponent aComponent) ; + NS_IMETHOD Append(nsComponent aComponent) ; + NS_IMETHOD Remove(nsComponent aComponent) ; + NS_IMETHOD RemoveAll() ; + NS_IMETHOD RemoveAt(PRUint32 aIndex) ; + + NS_IMETHOD CreateIterator(nsIIterator ** aIterator) ; + +protected: + ~nsVector(); + +private: + nsVoidArray * mVoidArray ; + +}; + +#endif /* nsVector_h___ */ diff --git a/mozilla/xpfc/util/inc/nsVectorIterator.h b/mozilla/xpfc/util/inc/nsVectorIterator.h new file mode 100644 index 00000000000..3cdbabbf42c --- /dev/null +++ b/mozilla/xpfc/util/inc/nsVectorIterator.h @@ -0,0 +1,53 @@ +/* -*- 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 nsVectorIterator_h___ +#define nsVectorIterator_h___ + +#include "nsIIterator.h" +#include "nsIVector.h" + +class nsVectorIterator : public nsIIterator +{ +public: + nsVectorIterator(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init() ; + NS_IMETHOD Init(nsIVector * aVector) ; + + NS_IMETHOD First() ; + NS_IMETHOD Last() ; + NS_IMETHOD Next() ; + NS_IMETHOD Previous() ; + NS_IMETHOD_(PRBool) IsDone() ; + NS_IMETHOD_(PRBool) IsFirst() ; + NS_IMETHOD_(nsComponent) CurrentItem() ; + NS_IMETHOD_(PRUint32) Count() ; + +protected: + ~nsVectorIterator(); + +private: + nsIVector * mVector; + PRUint32 mCurrentElement; + +}; + +#endif /* nsVectorIterator_h___ */ diff --git a/mozilla/xpfc/util/inc/nsxpfcutil.h b/mozilla/xpfc/util/inc/nsxpfcutil.h new file mode 100644 index 00000000000..548a5108427 --- /dev/null +++ b/mozilla/xpfc/util/inc/nsxpfcutil.h @@ -0,0 +1,26 @@ +/* -*- 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 nsxpfcutil_h___ +#define nsxpfcutil_h___ + +#define NewObject(a) new a +#define DeleteObject(a) delete a +#define DeleteIfObject(a) delete a ; a = nsnull + +#endif /* nsxpfcutil_h___ */ diff --git a/mozilla/xpfc/util/manifest.mn b/mozilla/xpfc/util/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/util/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/util/public/Makefile b/mozilla/xpfc/util/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/util/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/util/public/manifest.mn b/mozilla/xpfc/util/public/manifest.mn new file mode 100644 index 00000000000..5effd50fb01 --- /dev/null +++ b/mozilla/xpfc/util/public/manifest.mn @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIVector.h \ + nsIIterator.h \ + nsIStack.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/util/public/nsIIterator.h b/mozilla/xpfc/util/public/nsIIterator.h new file mode 100644 index 00000000000..3158b0ec7e1 --- /dev/null +++ b/mozilla/xpfc/util/public/nsIIterator.h @@ -0,0 +1,49 @@ +/* -*- 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 nsIIterator_h___ +#define nsIIterator_h___ + +#include "nsISupports.h" + +typedef void * nsComponent ; + +//0d985370-eb7c-11d1-9244-00805f8a7ab6 +#define NS_IITERATOR_IID \ +{ 0x0d985370, 0xeb7c, 0x11d1, \ +{ 0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsIIterator : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0 ; + + NS_IMETHOD First() = 0 ; + NS_IMETHOD Last() = 0 ; + NS_IMETHOD Next() = 0 ; + NS_IMETHOD Previous() = 0 ; + NS_IMETHOD_(PRBool) IsDone() = 0 ; + NS_IMETHOD_(PRBool) IsFirst() = 0 ; + NS_IMETHOD_(nsComponent) CurrentItem() = 0 ; + NS_IMETHOD_(PRUint32) Count() = 0 ; + +}; + +#endif /* nsIIterator_h___ */ diff --git a/mozilla/xpfc/util/public/nsIStack.h b/mozilla/xpfc/util/public/nsIStack.h new file mode 100644 index 00000000000..7e74f91a173 --- /dev/null +++ b/mozilla/xpfc/util/public/nsIStack.h @@ -0,0 +1,44 @@ +/* -*- 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 nsIStack_h___ +#define nsIStack_h___ + +#include "nsISupports.h" +#include "nsIIterator.h" + +//212ea530-27db-11d2-9246-00805f8a7ab6 +#define NS_ISTACK_IID \ +{ 0x212ea530, 0x27db, 0x11d2, \ +{ 0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsIStack : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0 ; + + NS_IMETHOD_(PRBool) Empty() = 0 ; + NS_IMETHOD Push(nsComponent aComponent) = 0; + NS_IMETHOD_(nsComponent) Pop() = 0; + NS_IMETHOD_(nsComponent) Top() = 0; + +}; + +#endif /* nsIStack_h___ */ diff --git a/mozilla/xpfc/util/public/nsIVector.h b/mozilla/xpfc/util/public/nsIVector.h new file mode 100644 index 00000000000..c6d40ee89e4 --- /dev/null +++ b/mozilla/xpfc/util/public/nsIVector.h @@ -0,0 +1,57 @@ +/* -*- 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 nsIVector_h___ +#define nsIVector_h___ + +#include "nsISupports.h" +#include "nsIIterator.h" + +//9d149d10-eb7f-11d1-9244-00805f8a7ab6 +#define NS_IVECTOR_IID \ +{ 0x9d149d10, 0xeb7c, 0x11d1, \ +{ 0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + + +typedef PRInt32 (*nsVectorCompareProc)(const nsComponent elem1, const nsComponent elem2 ); + +class nsIVector : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0 ; + + NS_IMETHOD_(PRUint32) Count() = 0 ; + NS_IMETHOD_(PRBool) Empty() = 0 ; + NS_IMETHOD_(PRBool) Contains(nsComponent aComponent) = 0; + NS_IMETHOD_(PRUint32) IndexOf(nsComponent aComponent) = 0; + NS_IMETHOD_(PRInt32) InsertBinary(nsComponent aComponent, nsVectorCompareProc aCompFn, PRBool bAllowDups) = 0; + NS_IMETHOD_(nsComponent) ElementAt(PRUint32 aIndex) = 0 ; + + NS_IMETHOD Insert(PRUint32 aIndex, nsComponent aComponent) = 0 ; + NS_IMETHOD Append(nsComponent aComponent) = 0 ; + NS_IMETHOD Remove(nsComponent aComponent) = 0 ; + NS_IMETHOD RemoveAll() = 0; + NS_IMETHOD RemoveAt(PRUint32 aIndex) = 0 ; + + NS_IMETHOD CreateIterator(nsIIterator ** aIterator) = 0 ; + +}; + +#endif /* nsIVector_h___ */ diff --git a/mozilla/xpfc/util/src/Makefile b/mozilla/xpfc/util/src/Makefile new file mode 100644 index 00000000000..b45bce18aa9 --- /dev/null +++ b/mozilla/xpfc/util/src/Makefile @@ -0,0 +1,52 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + diff --git a/mozilla/xpfc/util/src/config.mk b/mozilla/xpfc/util/src/config.mk new file mode 100644 index 00000000000..5385347d39f --- /dev/null +++ b/mozilla/xpfc/util/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES +=-I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = util +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/util/src/manifest.mn b/mozilla/xpfc/util/src/manifest.mn new file mode 100644 index 00000000000..6c4b57cde78 --- /dev/null +++ b/mozilla/xpfc/util/src/manifest.mn @@ -0,0 +1,27 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsVectorIterator.cpp \ + nsVector.cpp \ + nsStack.cpp \ + $(NULL) + +REQUIRES = xpcom raptor + diff --git a/mozilla/xpfc/util/src/nsStack.cpp b/mozilla/xpfc/util/src/nsStack.cpp new file mode 100644 index 00000000000..4c7a0b6a072 --- /dev/null +++ b/mozilla/xpfc/util/src/nsStack.cpp @@ -0,0 +1,78 @@ +/* -*- 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. + */ + +#include "nsStack.h" +#include "nsxpfcCIID.h" +#include "nsxpfcutil.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCStackCID, NS_STACK_CID); + +nsStack :: nsStack() +{ + NS_INIT_REFCNT(); + + mVoidArray = nsnull ; +} + +nsStack :: ~nsStack() +{ + DeleteIfObject(mVoidArray) ; +} + +NS_IMPL_QUERY_INTERFACE(nsStack, kCStackCID) +NS_IMPL_ADDREF(nsStack) +NS_IMPL_RELEASE(nsStack) + +nsresult nsStack :: Init() +{ + mVoidArray = NewObject(nsVoidArray) ; + + return NS_OK ; +} + +PRBool nsStack :: Empty() +{ + return (mVoidArray->Count() ? PR_TRUE : PR_FALSE) ; +} + +nsresult nsStack :: Push(nsComponent aComponent) +{ + nsresult res = NS_OK; + + if (PR_TRUE == mVoidArray->AppendElement(aComponent)) + return NS_OK ; + + return res ; +} + +nsComponent nsStack :: Pop() +{ + nsComponent component = mVoidArray->ElementAt(mVoidArray->Count()-1); + + if (PR_TRUE == mVoidArray->RemoveElementAt(mVoidArray->Count()-1)) + return component ; + + return nsnull ; +} + +nsComponent nsStack :: Top() +{ + return (mVoidArray->ElementAt(mVoidArray->Count()-1)) ; +} + diff --git a/mozilla/xpfc/util/src/nsUtilFactory.cpp b/mozilla/xpfc/util/src/nsUtilFactory.cpp new file mode 100644 index 00000000000..89417d2513c --- /dev/null +++ b/mozilla/xpfc/util/src/nsUtilFactory.cpp @@ -0,0 +1,175 @@ +/* -*- 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. + */ + +#include "nscore.h" +#include "nsIFactory.h" +#include "nsISupports.h" +#include "nsCalUtilCIID.h" + +#include "nsVector.h" +#include "nsVectorIterator.h" +#include "nsDateTime.h" +#include "nsDuration.h" +#include "nsStack.h" + +static NS_DEFINE_IID(kCVector, NS_VECTOR_CID); +static NS_DEFINE_IID(kCVectorIterator, NS_VECTOR_ITERATOR_CID); +static NS_DEFINE_IID(kCDateTime, NS_DATETIME_CID); +static NS_DEFINE_IID(kCDuration, NS_DURATION_CID); +static NS_DEFINE_IID(kCStack, NS_STACK_CID); + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); + +class nsUtilFactory : public nsIFactory +{ + public: + // nsISupports methods + NS_IMETHOD QueryInterface(const nsIID &aIID, + void **aResult); + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + + // nsIFactory methods + NS_IMETHOD CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + + nsUtilFactory(const nsCID &aClass); + ~nsUtilFactory(); + + private: + nsrefcnt mRefCnt; + nsCID mClassID; +}; + +nsUtilFactory::nsUtilFactory(const nsCID &aClass) +{ + mRefCnt = 0; + mClassID = aClass; +} + +nsUtilFactory::~nsUtilFactory() +{ + NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction"); +} + +nsresult nsUtilFactory::QueryInterface(const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aResult = NULL; + + if (aIID.Equals(kISupportsIID)) { + *aResult = (void *)(nsISupports*)this; + } else if (aIID.Equals(kIFactoryIID)) { + *aResult = (void *)(nsIFactory*)this; + } + + if (*aResult == NULL) { + return NS_NOINTERFACE; + } + + AddRef(); // Increase reference count for caller + return NS_OK; +} + +nsrefcnt nsUtilFactory::AddRef() +{ + return ++mRefCnt; +} + +nsrefcnt nsUtilFactory::Release() +{ + if (--mRefCnt == 0) { + delete this; + return 0; // Don't access mRefCnt after deleting! + } + return mRefCnt; +} + +nsresult nsUtilFactory::CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + nsISupports *inst = nsnull; + + if (mClassID.Equals(kCVector)) { + inst = (nsISupports *)new nsVector(); + } + else if (mClassID.Equals(kCVectorIterator)) { + inst = (nsISupports *)new nsVectorIterator(); + } + else if (mClassID.Equals(kCStack)) { + inst = (nsISupports *)new nsStack(); + } + else if (mClassID.Equals(kCDateTime)) { + inst = (nsISupports *)new nsDateTime(); + } + else if (mClassID.Equals(kCDuration)) { + inst = (nsISupports *)new nsDuration(); + } + + if (inst == NULL) { + return NS_ERROR_OUT_OF_MEMORY; + } + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) { + // We didn't get the right interface, so clean up + delete inst; + } + + return res; +} + +nsresult nsUtilFactory::LockFactory(PRBool aLock) +{ + // Not implemented in simplest case. + return NS_OK; +} + +// return the proper factory to the caller +extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory) +{ + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } + + *aFactory = new nsUtilFactory(aClass); + + if (nsnull == aFactory) { + return NS_ERROR_OUT_OF_MEMORY; + } + + return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); +} + diff --git a/mozilla/xpfc/util/src/nsVector.cpp b/mozilla/xpfc/util/src/nsVector.cpp new file mode 100644 index 00000000000..11f54823bdf --- /dev/null +++ b/mozilla/xpfc/util/src/nsVector.cpp @@ -0,0 +1,202 @@ +/* -*- 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. + */ + +#include "nsVector.h" +#include "nsVectorIterator.h" +#include "nsxpfcCIID.h" +#include "nsxpfcutil.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + +nsVector :: nsVector() +{ + NS_INIT_REFCNT(); + + mVoidArray = nsnull ; +} + +nsVector :: ~nsVector() +{ + DeleteIfObject(mVoidArray) ; +} + +NS_IMPL_QUERY_INTERFACE(nsVector, kCVectorCID) +NS_IMPL_ADDREF(nsVector) +NS_IMPL_RELEASE(nsVector) + +nsresult nsVector :: Init() +{ + mVoidArray = NewObject(nsVoidArray) ; + + return NS_OK ; +} + +PRUint32 nsVector :: Count() +{ + return mVoidArray->Count() ; +} + +PRBool nsVector :: Empty() +{ + return (Count() ? PR_TRUE : PR_FALSE) ; +} + +PRBool nsVector :: Contains(nsComponent aComponent) +{ + if (IndexOf(aComponent)) + return PR_TRUE ; + else + return PR_FALSE ; +} + +PRUint32 nsVector :: IndexOf(nsComponent aComponent) +{ + return (mVoidArray->IndexOf(aComponent)) ; +} + +nsComponent nsVector :: ElementAt(PRUint32 aIndex) +{ + return (mVoidArray->ElementAt(aIndex)) ; ; +} + +/* + * Inserts an element into the list in a sorted fashion. + * @param newElement the element to insert + * @param compare the sorting function + * @param bAllowDups if TRUE-> insert duplicates into the list, if FALSE-> don't insert duplicates in the list + * @returns -1 means that the element existed and that dupliates were not allowed, so it was not inserted. + * 0 means the element was inserted, no problems + * 1 means the element was not inserted because of an internal error + */ +PRInt32 nsVector::InsertBinary(nsComponent newElement, nsVectorCompareProc aCompareFn, PRBool bAllowDups) +{ + PRInt32 iCurrent = 0; + PRInt32 iLeft = 0; + PRInt32 iRight = Count() - 1; + PRInt32 iCompare = 0; + + while (iLeft <= iRight) + { + iCurrent = (iLeft + iRight) / 2; + void* pCurrent = ElementAt(iCurrent); + iCompare = aCompareFn(&pCurrent, &newElement); + if (iCompare == 0) + { + if (0 == bAllowDups) + return -1; + else + break; + } + else if (iCompare > 0) + iRight = iCurrent - 1; + else + iLeft = iCurrent + 1; + } + + if (iCompare < 0) + iCurrent += 1; + if (PR_TRUE == mVoidArray->InsertElementAt(newElement, iCurrent)) + return 0; + return 1; +} + +nsresult nsVector :: Insert(PRUint32 aIndex, nsComponent aComponent) +{ + nsresult res = NS_OK; + + if (PR_TRUE == mVoidArray->InsertElementAt(aComponent, aIndex)) + return NS_OK ; + + // XXX What to return here + return res ; +} + +nsresult nsVector :: Append(nsComponent aComponent) +{ + nsresult res = NS_OK; + + if (PR_TRUE == mVoidArray->AppendElement(aComponent)) + return NS_OK ; + + // XXX What to return here + return res ; +} + +nsresult nsVector :: Remove(nsComponent aComponent) +{ + nsresult res = NS_OK; + + if (PR_TRUE == mVoidArray->RemoveElement(aComponent)) + return NS_OK ; + + // XXX What to return here + return res ; +} + +nsresult nsVector :: RemoveAll() +{ + mVoidArray->Clear(); + + return NS_OK ; +} + +nsresult nsVector :: RemoveAt(PRUint32 aIndex) +{ + nsresult res = NS_OK; + + if (PR_TRUE == mVoidArray->RemoveElementAt(aIndex)) + return NS_OK ; + + // XXX What to return here + return res ; +} + +nsresult nsVector :: CreateIterator(nsIIterator ** aIterator) +{ + static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID); + + nsresult res ; + +#ifdef NS_WIN32 + #define XPFC_DLL "xpfc10.dll" +#else + #define XPFC_DLL "libxpfc10.so" +#endif + + nsRepository::RegisterFactory(kCVectorIteratorCID, XPFC_DLL, PR_FALSE, PR_FALSE); + + nsVectorIterator * aVectorIterator ; + + *aIterator = nsnull; + + res = nsRepository::CreateInstance(kCVectorIteratorCID, + nsnull, + kCVectorIteratorCID, + (void **)&aVectorIterator); + + if (NS_OK != res) + return res ; + + aVectorIterator->Init(this); + + *aIterator = (nsIIterator *) aVectorIterator; + + return res ; +} + diff --git a/mozilla/xpfc/util/src/nsVectorIterator.cpp b/mozilla/xpfc/util/src/nsVectorIterator.cpp new file mode 100644 index 00000000000..01085c5d5ea --- /dev/null +++ b/mozilla/xpfc/util/src/nsVectorIterator.cpp @@ -0,0 +1,121 @@ +/* -*- 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. + */ + +#include "nscore.h" +#include "nsIIterator.h" +#include "nsxpfcCIID.h" +#include "nsIVector.h" +#include "nsVectorIterator.h" +#include "nsxpfcutil.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID); + +nsVectorIterator :: nsVectorIterator() +{ + NS_INIT_REFCNT(); + mCurrentElement = 0 ; +} + +nsVectorIterator :: ~nsVectorIterator() +{ +} + +NS_IMPL_QUERY_INTERFACE(nsVectorIterator, kCVectorIteratorCID) +NS_IMPL_ADDREF(nsVectorIterator) +NS_IMPL_RELEASE(nsVectorIterator) + +nsresult nsVectorIterator :: Init() +{ + mCurrentElement = 0 ; + return NS_OK ; +} + +nsresult nsVectorIterator :: Init(nsIVector * aVector) +{ + mVector = aVector; + mCurrentElement = 0 ; + return NS_OK ; +} + +nsresult nsVectorIterator :: First() +{ + mCurrentElement = 0 ; + return NS_OK ; +} + +nsresult nsVectorIterator :: Last() +{ + mCurrentElement = Count() - 1 ; + return NS_OK ; +} + +nsresult nsVectorIterator :: Next() +{ + mCurrentElement++; + return NS_OK ; +} + +nsresult nsVectorIterator :: Previous() +{ + mCurrentElement--; + return NS_OK ; +} + +PRBool nsVectorIterator :: IsDone() +{ + if (mVector == nsnull) + return PR_TRUE; + + if ((mVector->Count()) == (mCurrentElement)) + return PR_TRUE; + + return PR_FALSE ; +} + +PRBool nsVectorIterator :: IsFirst() +{ + if (mVector == nsnull) + return PR_TRUE; + + if (0 == (mCurrentElement)) + return PR_TRUE; + + return PR_FALSE ; +} + +nsComponent nsVectorIterator :: CurrentItem() +{ + if (IsDone()) + return nsnull ; + + return (mVector->ElementAt(mCurrentElement)); +} + +PRUint32 nsVectorIterator :: Count() +{ + return (mVector->Count()); +} + + + + + + + + diff --git a/mozilla/xpfc/widget/Makefile b/mozilla/xpfc/widget/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/widget/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/widget/inc/Makefile b/mozilla/xpfc/widget/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/widget/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/widget/inc/manifest.mn b/mozilla/xpfc/widget/inc/manifest.mn new file mode 100644 index 00000000000..acbde69cabe --- /dev/null +++ b/mozilla/xpfc/widget/inc/manifest.mn @@ -0,0 +1,23 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + nsXPFCButton.h \ + nsXPFCTabWidget.h \ + nsXPFCTextWidget.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/widget/inc/nsXPFCButton.h b/mozilla/xpfc/widget/inc/nsXPFCButton.h new file mode 100644 index 00000000000..42ec8f5db2d --- /dev/null +++ b/mozilla/xpfc/widget/inc/nsXPFCButton.h @@ -0,0 +1,51 @@ +/* -*- 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 nsXPFCButton_h___ +#define nsXPFCButton_h___ + +#include "nsIXPFCButton.h" +#include "nsXPFCCanvas.h" + +class nsXPFCButton : public nsIXPFCButton, + public nsXPFCCanvas + +{ +public: + nsXPFCButton(nsISupports* outer); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + NS_IMETHOD GetClassPreferredSize(nsSize& aSize); + + NS_IMETHOD CreateWidget(); + + NS_IMETHOD SetLabel(nsString& aString); + NS_IMETHOD SetBounds(const nsRect& aBounds); + NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent); + +protected: + ~nsXPFCButton(); + + +}; + +#endif /* nsXPFCButton_h___ */ diff --git a/mozilla/xpfc/widget/inc/nsXPFCTabWidget.h b/mozilla/xpfc/widget/inc/nsXPFCTabWidget.h new file mode 100644 index 00000000000..4aba2a22dbd --- /dev/null +++ b/mozilla/xpfc/widget/inc/nsXPFCTabWidget.h @@ -0,0 +1,46 @@ +/* -*- 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 nsXPFCTabWidget_h___ +#define nsXPFCTabWidget_h___ + +#include "nsIXPFCTabWidget.h" +#include "nsXPFCCanvas.h" + +class nsXPFCTabWidget : public nsIXPFCTabWidget, + public nsXPFCCanvas + +{ +public: + nsXPFCTabWidget(nsISupports* outer); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + NS_IMETHOD GetClassPreferredSize(nsSize& aSize); + NS_IMETHOD CreateWidget(); + +protected: + ~nsXPFCTabWidget(); + + +}; + +#endif /* nsXPFCTabWidget_h___ */ diff --git a/mozilla/xpfc/widget/inc/nsXPFCTextWidget.h b/mozilla/xpfc/widget/inc/nsXPFCTextWidget.h new file mode 100644 index 00000000000..0b46998d601 --- /dev/null +++ b/mozilla/xpfc/widget/inc/nsXPFCTextWidget.h @@ -0,0 +1,47 @@ +/* -*- 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 nsXPFCTextWidget_h___ +#define nsXPFCTextWidget_h___ + +#include "nsIXPFCTextWidget.h" +#include "nsXPFCCanvas.h" + +class nsXPFCTextWidget : public nsIXPFCTextWidget, + public nsXPFCCanvas + +{ +public: + nsXPFCTextWidget(nsISupports* outer); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + NS_IMETHOD GetClassPreferredSize(nsSize& aSize); + NS_IMETHOD CreateWidget(); + NS_IMETHOD SetLabel(nsString& aString); + +protected: + ~nsXPFCTextWidget(); + + +}; + +#endif /* nsXPFCTextWidget_h___ */ diff --git a/mozilla/xpfc/widget/manifest.mn b/mozilla/xpfc/widget/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/widget/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/widget/public/Makefile b/mozilla/xpfc/widget/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/widget/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/widget/public/manifest.mn b/mozilla/xpfc/widget/public/manifest.mn new file mode 100644 index 00000000000..47c3b327f9c --- /dev/null +++ b/mozilla/xpfc/widget/public/manifest.mn @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIXPFCButton.h \ + nsIXPFCTextWidget.h \ + nsIXPFCTabWidget.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/widget/public/nsIXPFCButton.h b/mozilla/xpfc/widget/public/nsIXPFCButton.h new file mode 100644 index 00000000000..fffa3356d6a --- /dev/null +++ b/mozilla/xpfc/widget/public/nsIXPFCButton.h @@ -0,0 +1,38 @@ +/* -*- 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 nsIXPFCButton_h___ +#define nsIXPFCButton_h___ + +#include "nsISupports.h" + +//ff6fd4c0-3b97-11d2-bee0-00805f8a8dbd +#define NS_IXPFC_BUTTON_IID \ + { 0xff6fd4c0, 0x3b97, 0x11d2, \ + {0xbe, 0xe0, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +class nsIXPFCButton : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; +}; + +#endif /* nsIXPFCButton_h___ */ + diff --git a/mozilla/xpfc/widget/public/nsIXPFCTabWidget.h b/mozilla/xpfc/widget/public/nsIXPFCTabWidget.h new file mode 100644 index 00000000000..bf4467cfc17 --- /dev/null +++ b/mozilla/xpfc/widget/public/nsIXPFCTabWidget.h @@ -0,0 +1,38 @@ +/* -*- 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 nsIXPFCTabWidget_h___ +#define nsIXPFCTabWidget_h___ + +#include "nsISupports.h" + +//491d0190-3b99-11d2-bee0-00805f8a8dbd +#define NS_IXPFC_TABWIDGET_IID \ + { 0x491d0190, 0x3b99, 0x11d2, \ + {0xbe, 0xe0, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +class nsIXPFCTabWidget : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; +}; + +#endif /* nsIXPFCTabWidget_h___ */ + diff --git a/mozilla/xpfc/widget/public/nsIXPFCTextWidget.h b/mozilla/xpfc/widget/public/nsIXPFCTextWidget.h new file mode 100644 index 00000000000..37a9093f429 --- /dev/null +++ b/mozilla/xpfc/widget/public/nsIXPFCTextWidget.h @@ -0,0 +1,38 @@ +/* -*- 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 nsIXPFCTextWidget_h___ +#define nsIXPFCTextWidget_h___ + +#include "nsISupports.h" + +//128cdca0-3b99-11d2-bee0-00805f8a8dbd +#define NS_IXPFC_TEXTWIDGET_IID \ + { 0x128cdca0, 0x3b99, 0x11d2, \ + {0xbe, 0xe0, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +class nsIXPFCTextWidget : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; +}; + +#endif /* nsIXPFCTextWidget_h___ */ + diff --git a/mozilla/xpfc/widget/src/Makefile b/mozilla/xpfc/widget/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/widget/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/widget/src/config.mk b/mozilla/xpfc/widget/src/config.mk new file mode 100644 index 00000000000..3fe78abc005 --- /dev/null +++ b/mozilla/xpfc/widget/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = widget +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/widget/src/manifest.mn b/mozilla/xpfc/widget/src/manifest.mn new file mode 100644 index 00000000000..9c639af5e79 --- /dev/null +++ b/mozilla/xpfc/widget/src/manifest.mn @@ -0,0 +1,27 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsXPFCButton.cpp \ + nsXPFCTabWidget.cpp \ + nsXPFCTextWidget.cpp \ + $(NULL) + +REQUIRES = xpcom raptor netlib + diff --git a/mozilla/xpfc/widget/src/nsXPFCButton.cpp b/mozilla/xpfc/widget/src/nsXPFCButton.cpp new file mode 100644 index 00000000000..31dd5624bdf --- /dev/null +++ b/mozilla/xpfc/widget/src/nsXPFCButton.cpp @@ -0,0 +1,209 @@ +/* -*- 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. + */ + +#include "nsXPFCButton.h" +#include "nsxpfcCIID.h" +#include "nspr.h" +#include "nsIButton.h" +#include "nsWidgetsCID.h" +#include "nsXPFCToolkit.h" + +#include "nsIAppShell.h" +#include "nsIWidget.h" +#include "nsITextWidget.h" +#include "nsIButton.h" +#include "nsIImageGroup.h" +#include "nsITimer.h" +#include "nsIThrobber.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCXPFCButtonCID, NS_XPFC_BUTTON_CID); +static NS_DEFINE_IID(kCIXPFCButtonIID, NS_IXPFC_BUTTON_IID); +static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID); +static NS_DEFINE_IID(kInsButtonIID, NS_IBUTTON_IID); + +static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID); +static NS_DEFINE_IID(kIThrobberIID, NS_ITHROBBER_IID); + +#define DEFAULT_WIDTH 50 +#define DEFAULT_HEIGHT 50 + +static nsIThrobber * mThrobber = nsnull; + +nsXPFCButton :: nsXPFCButton(nsISupports* outer) : nsXPFCCanvas(outer) +{ + NS_INIT_REFCNT(); +} + +nsXPFCButton :: ~nsXPFCButton() +{ +} + +nsresult nsXPFCButton::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + static NS_DEFINE_IID(kClassIID, kCXPFCButtonCID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) (nsXPFCButton *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kCIXPFCButtonIID)) { + *aInstancePtr = (void*) (nsIXPFCButton *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return (nsXPFCCanvas::QueryInterface(aIID, aInstancePtr)); +} + +NS_IMPL_ADDREF(nsXPFCButton) +NS_IMPL_RELEASE(nsXPFCButton) + +nsresult nsXPFCButton :: Init() +{ + nsresult res = nsXPFCCanvas::Init(); + + return res; +} + +nsresult nsXPFCButton :: SetParameter(nsString& aKey, nsString& aValue) +{ + return (nsXPFCCanvas::SetParameter(aKey, aValue)); +} + +nsresult nsXPFCButton :: GetClassPreferredSize(nsSize& aSize) +{ + aSize.width = DEFAULT_WIDTH; + aSize.height = DEFAULT_HEIGHT; + return (NS_OK); +} + +nsresult nsXPFCButton :: CreateWidget() +{ + nsresult res = NS_OK; + + if (GetLabel() == "Throbber") + { + res = nsRepository::CreateInstance(kThrobberCID, + nsnull, + kIThrobberIID, + (void**)&mThrobber); + if (NS_OK != res) + return res; + + nsIWidget * parent = GetWidget(); + + nsSize size ; + + GetClassPreferredSize(size); + + nsRect rect(0,0,size.width,size.height); + + mThrobber->Init(parent, rect); + + mThrobber->Show(); + + } else { + + + nsIWidget * parent = GetWidget(); + + res = LoadWidget(kCButtonCID); + + nsIButton * button = nsnull; + res = QueryInterface(kInsButtonIID,(void**)&button); + + if (NS_OK == res) + { + nsSize size ; + + GetClassPreferredSize(size); + + nsRect rect(0,0,size.width,size.height); + + button->Create(parent, + rect, + gXPFCToolkit->GetShellEventCallback(), + nsnull); + + button->SetLabel(GetLabel()); + button->SetBackgroundColor(GetBackgroundColor()); + button->SetForegroundColor(GetForegroundColor()); + button->Show(PR_TRUE); + NS_RELEASE(button); + } + + SetVisibility(PR_FALSE); + } + return res; +} + +nsresult nsXPFCButton :: SetLabel(nsString& aString) +{ + nsXPFCCanvas::SetLabel(aString); + + /* + * If we are aggregating a button, set it specifically + * + * At this point we probably want to offer implementations + * of the needed widgets! + */ + static NS_DEFINE_IID(kInsButtonIID, NS_IBUTTON_IID); + + nsIButton * button = nsnull; + nsresult res = QueryInterface(kInsButtonIID,(void**)&button); + + if (NS_OK == res) + { + button->SetLabel(aString); + NS_RELEASE(button); + } + + return NS_OK; +} + +nsresult nsXPFCButton :: SetBounds(const nsRect &aBounds) +{ + + if (mWidget == nsnull) + { + mThrobber->MoveTo(aBounds.x, aBounds.y); + return NS_OK; + } + + return (nsXPFCCanvas::SetBounds(aBounds)); + +} + +nsEventStatus nsXPFCButton :: OnPaint(nsGUIEvent *aEvent) +{ + if (GetLabel() == "Throbber") + { + mThrobber->Hide(); + mThrobber->Show(); + } + return (nsXPFCCanvas::OnPaint(aEvent)); +} \ No newline at end of file diff --git a/mozilla/xpfc/widget/src/nsXPFCTabWidget.cpp b/mozilla/xpfc/widget/src/nsXPFCTabWidget.cpp new file mode 100644 index 00000000000..69f1a1cf238 --- /dev/null +++ b/mozilla/xpfc/widget/src/nsXPFCTabWidget.cpp @@ -0,0 +1,123 @@ +/* -*- 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. + */ + +#include "nsXPFCTabWidget.h" +#include "nsxpfcCIID.h" +#include "nspr.h" +#include "nsITabWidget.h" +#include "nsWidgetsCID.h" +#include "nsXPFCToolkit.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCXPFCTabWidgetCID, NS_XPFC_TABWIDGET_CID); +static NS_DEFINE_IID(kCIXPFCTabWidgetIID, NS_IXPFC_TABWIDGET_IID); +static NS_DEFINE_IID(kCTabWidgetCID, NS_TABWIDGET_CID); +static NS_DEFINE_IID(kInsTabWidgetIID, NS_ITABWIDGET_IID); + +#define DEFAULT_WIDTH 50 +#define DEFAULT_HEIGHT 50 + +nsXPFCTabWidget :: nsXPFCTabWidget(nsISupports* outer) : nsXPFCCanvas(outer) +{ + NS_INIT_REFCNT(); +} + +nsXPFCTabWidget :: ~nsXPFCTabWidget() +{ +} + +nsresult nsXPFCTabWidget::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + static NS_DEFINE_IID(kClassIID, kCXPFCTabWidgetCID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) (nsXPFCTabWidget *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kCIXPFCTabWidgetIID)) { + *aInstancePtr = (void*) (nsIXPFCTabWidget *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return (nsXPFCCanvas::QueryInterface(aIID, aInstancePtr)); +} + +NS_IMPL_ADDREF(nsXPFCTabWidget) +NS_IMPL_RELEASE(nsXPFCTabWidget) + +nsresult nsXPFCTabWidget :: Init() +{ + nsresult res = nsXPFCCanvas::Init(); + + return res; +} + +nsresult nsXPFCTabWidget :: SetParameter(nsString& aKey, nsString& aValue) +{ + return (nsXPFCCanvas::SetParameter(aKey, aValue)); +} + +nsresult nsXPFCTabWidget :: GetClassPreferredSize(nsSize& aSize) +{ + aSize.width = DEFAULT_WIDTH; + aSize.height = DEFAULT_HEIGHT; + return (NS_OK); +} + +nsresult nsXPFCTabWidget :: CreateWidget() +{ + nsresult res; + + nsIWidget * parent = GetWidget(); + + res = LoadWidget(kCTabWidgetCID); + + nsITabWidget * tab_widget = nsnull; + res = QueryInterface(kInsTabWidgetIID,(void**)&tab_widget); + + if (NS_OK == res) + { + nsSize size ; + + GetClassPreferredSize(size); + + nsRect rect(0,0,size.width,size.height); + + tab_widget->Create(parent, + rect, + gXPFCToolkit->GetShellEventCallback(), + nsnull); + + tab_widget->Show(PR_TRUE); + SetParameter(nsString("tab1"),nsString("Tab1")); + NS_RELEASE(tab_widget); + } + + SetVisibility(PR_FALSE); + + return res; +} diff --git a/mozilla/xpfc/widget/src/nsXPFCTextWidget.cpp b/mozilla/xpfc/widget/src/nsXPFCTextWidget.cpp new file mode 100644 index 00000000000..afb76633e31 --- /dev/null +++ b/mozilla/xpfc/widget/src/nsXPFCTextWidget.cpp @@ -0,0 +1,137 @@ +/* -*- 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. + */ + +#include "nsXPFCTextWidget.h" +#include "nsxpfcCIID.h" +#include "nspr.h" +#include "nsITextWidget.h" +#include "nsWidgetsCID.h" +#include "nsXPFCToolkit.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCXPFCTextWidgetCID, NS_XPFC_TEXTWIDGET_CID); +static NS_DEFINE_IID(kCIXPFCTextWidgetIID, NS_IXPFC_TEXTWIDGET_IID); +static NS_DEFINE_IID(kCTextWidgetCID, NS_TEXTFIELD_CID); +static NS_DEFINE_IID(kInsTextWidgetIID, NS_ITEXTWIDGET_IID); + +#define DEFAULT_WIDTH 50 +#define DEFAULT_HEIGHT 50 + +nsXPFCTextWidget :: nsXPFCTextWidget(nsISupports* outer) : nsXPFCCanvas(outer) +{ + NS_INIT_REFCNT(); +} + +nsXPFCTextWidget :: ~nsXPFCTextWidget() +{ +} + +nsresult nsXPFCTextWidget::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + static NS_DEFINE_IID(kClassIID, kCXPFCTextWidgetCID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) (nsXPFCTextWidget *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kCIXPFCTextWidgetIID)) { + *aInstancePtr = (void*) (nsIXPFCTextWidget *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return (nsXPFCCanvas::QueryInterface(aIID, aInstancePtr)); +} + +NS_IMPL_ADDREF(nsXPFCTextWidget) +NS_IMPL_RELEASE(nsXPFCTextWidget) + +nsresult nsXPFCTextWidget :: Init() +{ + nsresult res = nsXPFCCanvas::Init(); + + return res; +} + +nsresult nsXPFCTextWidget :: SetParameter(nsString& aKey, nsString& aValue) +{ + return (nsXPFCCanvas::SetParameter(aKey, aValue)); +} + +nsresult nsXPFCTextWidget :: GetClassPreferredSize(nsSize& aSize) +{ + aSize.width = DEFAULT_WIDTH; + aSize.height = DEFAULT_HEIGHT; + return (NS_OK); +} + + +nsresult nsXPFCTextWidget :: CreateWidget() +{ + + nsresult res; + + nsIWidget * parent = GetWidget(); + + res = LoadWidget(kCTextWidgetCID); + + nsITextWidget * text_widget = nsnull; + res = QueryInterface(kInsTextWidgetIID,(void**)&text_widget); + + if (NS_OK == res) + { + nsSize size ; + + GetClassPreferredSize(size); + + nsRect rect(0,0,size.width,size.height); + + text_widget->Create(parent, + rect, + gXPFCToolkit->GetShellEventCallback(), + nsnull); + + text_widget->SetText(GetLabel()); + text_widget->SetBackgroundColor(GetBackgroundColor()); + text_widget->SetForegroundColor(GetForegroundColor()); + text_widget->Show(PR_TRUE); + + if (gXPFCToolkit->GetCanvasManager()->GetFocusedCanvas() == this) + SetFocus(); + + NS_RELEASE(text_widget); + } + + SetVisibility(PR_FALSE); + + return res; +} + +nsresult nsXPFCTextWidget :: SetLabel(nsString& aString) +{ + nsXPFCCanvas::SetLabel(aString); + return NS_OK; +}