зеркало из https://github.com/mozilla/pjs.git
First pass at XPFC migration to Free Source repo
This commit is contained in:
Родитель
11941ed1bb
Коммит
20ff26d1fc
|
@ -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
|
|
@ -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___ */
|
|
@ -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___ */
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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___ */
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
|
@ -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___ */
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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___ */
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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___ */
|
|
@ -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___ */
|
|
@ -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___ */
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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___ */
|
|
@ -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___ */
|
|
@ -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___ */
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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___ */
|
|
@ -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
|
||||
|
||||
|
|
@ -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
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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___ */
|
|
@ -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___ */
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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= "<!DOCTYPE menubar";
|
||||
static const char* kToolbarXMLTextContentType = "ui/toolbar";
|
||||
static const char* kToolbarXMLDocHeader= "<!DOCTYPE toolbar";
|
||||
static const char* kDialogXMLTextContentType = "ui/dialog";
|
||||
static const char* kDialogXMLDocHeader= "<!DOCTYPE dialog";
|
||||
|
||||
struct nsXPFCXMLTagEntry {
|
||||
char mName[32];
|
||||
eXPFCXMLTags fTagID;
|
||||
};
|
||||
|
||||
nsXPFCXMLTagEntry gXPFCXMLTagTable[] =
|
||||
{
|
||||
{"!!UNKNOWN", eXPFCXMLTag_unknown},
|
||||
{"!DOCTYPE", eXPFCXMLTag_doctype},
|
||||
{"?XML", eXPFCXMLTag_xml},
|
||||
{"button", eXPFCXMLTag_button},
|
||||
{"canvas", eXPFCXMLTag_canvas},
|
||||
{"dialog", eXPFCXMLTag_dialog},
|
||||
{"editfield", eXPFCXMLTag_editfield},
|
||||
{"menubar", eXPFCXMLTag_menubar},
|
||||
{"menucontainer", eXPFCXMLTag_menucontainer},
|
||||
{"menuitem", eXPFCXMLTag_menuitem},
|
||||
{"object", eXPFCXMLTag_object},
|
||||
{"separator", eXPFCXMLTag_separator},
|
||||
{"set", eXPFCXMLTag_set},
|
||||
{"tabwidget", eXPFCXMLTag_tabwidget},
|
||||
{"toolbar", eXPFCXMLTag_toolbar},
|
||||
{"ui", eXPFCXMLTag_ui},
|
||||
|
||||
};
|
||||
|
||||
eXPFCXMLTags DetermineXPFCXMLTagType(const nsString& aString)
|
||||
{
|
||||
PRInt32 result=-1;
|
||||
PRInt32 cnt=sizeof(gXPFCXMLTagTable)/sizeof(nsXPFCXMLTagEntry);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=0;
|
||||
|
||||
while(low<=high){
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
//result=aString.Compare(gXPFCXMLTagTable[middle].mName, nsCRT::strlen(gXPFCXMLTagTable[middle].mName), PR_TRUE);
|
||||
result=aString.Compare(gXPFCXMLTagTable[middle].mName, PR_TRUE);
|
||||
if (result==0)
|
||||
return gXPFCXMLTagTable[middle].fTagID;
|
||||
if (result<0)
|
||||
high=middle-1;
|
||||
else low=middle+1;
|
||||
}
|
||||
return eXPFCXMLTag_userdefined;
|
||||
}
|
||||
|
||||
|
||||
PRInt32 XPFCXMLDispatchTokenHandler(CToken* aToken,nsIDTD* aDTD) {
|
||||
|
||||
PRInt32 result=0;
|
||||
|
||||
eHTMLTokenTypes theType= (eHTMLTokenTypes)aToken->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);
|
||||
|
||||
}
|
|
@ -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
|
|
@ -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
|
|
@ -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 <stdio.h>
|
||||
#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;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -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();
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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___ */
|
|
@ -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___ */
|
||||
|
|
@ -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___ */
|
|
@ -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___ */
|
|
@ -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
|
||||
|
|
@ -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 <Xm/Xm.h>
|
||||
#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 ;
|
||||
}
|
|
@ -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 <stdio.h>
|
||||
#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 <Xm/Xm.h>
|
||||
#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));
|
||||
}
|
||||
|
|
@ -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 <stdio.h>
|
||||
#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;
|
||||
}
|
||||
|
|
@ -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 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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 <windows.h>
|
||||
#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);
|
||||
}
|
|
@ -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
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
|
@ -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 <stdio.h>
|
||||
#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
|
|
@ -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___ */
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче